Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Arduino Microcontrollers

Similar presentations


Presentation on theme: "Introduction to Arduino Microcontrollers"— Presentation transcript:

1 Introduction to Arduino Microcontrollers

2 Microcontrollers – One Definition
Programmers work in the virtual world. Machinery works in the physical world. How does one connect the virtual world to the physical world? Enter the microcontroller. A microcontroller is basically a small-scale computer with generalized (and programmable) inputs and outputs. The inputs and outputs can be manipulated by and can manipulate the physical world.

3 Microcontrollers – One Definition
A microcontroller is basically a small-scale computer with a small amount of memory and generalized (and programmable) inputs and outputs. The inputs and outputs can be manipulated by and can manipulate the physical world.

4 Arduino Uno Close Up The pins are in three groups: 14 digital pins
6 analog pins power

5 Handling the Arduino - How NOT to Do It!
Improper Handling - NEVER!!!

6 Handling the Arduino - The Proper Way
Proper Handling - by the edges!!! Wash your hands after handling the boards. Solder contains lead (not RoHS compliant yet!)

7 Your Arduino Kit Should Include:
3 each, LEDs 1 each, Laptop 3 each, 220 W Resistors 1 each, USB cable 1 each, Breadboard 1 each, Arduino Pass out the checklists and inform students that they will be held responsible for all material lost or damaged (Unmet Obligations). The USB cable in your kit is blue, not black. The USB side plugs into the laptop and the other plugs into the Arduino board. 5 each, Jumper Wires

8 You and Your Partner Should:
Collect your Arduino Kit Inventory your kit to ensure all parts are present Complete and sign your checklist Turn in signed Checklist and sign out a Laptop Remember the # on your Laptop, you will get the same laptop each day

9 Connecting the Arduino to a Laptop/PC
Connect the Arduino UNO board to the laptop as shown in the picture to the right. One end of the cable should slide into one of the USB ports on the laptop; the other end of the cable attaches to the port on the UNO board. You should see the LED lights on the board come on when the connections are secure. Wash your hands after handling the boards. Solder contains lead (not RoHS compliant yet!)

10 Opening the Arduino Software
After you have connected your Arduino to the laptop: Look for the Arduino Software icon on the desktop of your laptop. Open the software. Click on Tools->Serial Port Find and click on the Com Port being used by your Arduino

11 Select Serial Port and Board

12 Programming - Routines
Each Arduino program is called a SKETCH and has two required functions, called ROUTINES. Type the code in RED below into your SKETCH. void setup ( ) { } - All of the code within the curly braces will be run ONCE when the program first runs. void loop ( ) { } - This function is run AFTER setup has finished. All of the code within the curly braces will be run again, and again, until the power is removed.

13 Arduino IDE Name of sketch Compile sketch Upload to board
Serial Monitor Program area Save New Open Messages and errors

14 A Little Bit About Programming
Code is case sensitive Statements are commands and must end with a semi-colon Comments follow a // or begin with /* and end with */ loop and setup

15 Digital I/0 pinMode(pin, mode) digitalRead(pin)
pinMode(pin, mode) Sets pin to either INPUT or OUTPUT digitalRead(pin) Reads HIGH or LOW from a pin digitalWrite(pin, value) Writes HIGH or LOW to a pin Electronic stuff Output pins can provide 40 mA of current Writing HIGH to an input pin installs a 20KΩ pullup

16 Terminology

17 Arduino Timing delay(ms) delayMicroseconds(us)
Pauses for a few milliseconds delayMicroseconds(us) Pauses for a few microseconds More commands: arduino.cc/en/Reference/HomePage

18 Upload the code Upload your sketch by clicking on this arrow.

19 Programming - Routines
Type the code in RED below into your SKETCH. void setup ( ) { pinMode(13, OUTPUT); } The Arduino C programming language is case-sensitive. Type in the code in RED exactly as you see it!!! void loop ( ) { digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); }

20 Notes: Resistor is needed to limit current Resistor and LED may be interchanged (but polarity of LED is important) Pin 13 is special: has built-in resistor and LED Change program and upload

21 Write “Blink” code Compile, then upload the program Congratulations!
You are now blinkers!

22 Status Messages todbot.com/blog/bionicarduino

23 Blink Challenges: Modify the code to blink the light on for 2 seconds then off for 3 seconds. Notice how bright the LED appears when it is on. Modify the code to blink the LED on for 1/10 of a second and off for 1/10 of a second. Does the LED blink? Is it as bright as before? What do you think causes the difference?

24 Digital? Analog? Digital has two values: on and off
Analog has many (infinite) values Computers don’t really do analog, they quantize Remember the 6 analog input pins---here’s how they work todbot.com/blog/bionicarduino


Download ppt "Introduction to Arduino Microcontrollers"

Similar presentations


Ads by Google