Microprocessors Tutorial 1: Arduino Basics Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog 7. MAKE: Volume control 8. Links Arduino Hardware Reset button 14 Digital Pins (6 PWM) USB ATMega 328 Power 6 Analog Pins Arduino Software Menu bar: set device, port, find examples Code: setup(), set pin direction pinMode(pin, IN/OUTPUT) loop(), set pin value with digitalWrite(led, HIGH/LOW) Or get pin value with digitalRead(pin) Buttons: verify and upload code MAKE: Blink Using built in LED, so no further electronics needed! 1. Connect Arduino Windows driver found? Correct port? 2. Upload code Electronics Breadboard: vertical connections, horizontal buses LEDs: polarized, long == + Resistor: Color-coded. Need one for LED Push Button: completes circuit only while pushed. Use a pull down resistor! MAKE: LED control Hardware 1. Connect buses to bread board, 5v and GND 2. Connect LED, pin->220ohm -> LED+ ->GND 1. Connect button, 5v ->button ->10kohm ->GND before res ->pin MAKE: LED control Software 1. Declare 2 pins outside and set direction in setup() 2. Read button state 3. If button is on, write desired output to LEDs Analog Digital: 0-1, On/Off LEDs, switches digitalRead(), digitalWrite() Analog: 0-1023 Potentiometer, sensor, motors AnalogRead(), analogWrite() Potentiometer: variable resistance +5v to pin MAKE: Volume Indicator Hardware 1. Add more LEDs, each going to a different pin 1. Connect potentiometer, center connection to pin MAKE: Volume Indicator Software 1. Add LED pin variables and set direction 2. Add pot pin, analog pin don't need direciton 3. Get pot value 4. Scale it using map(number, origStart, origEnd, scaledStart, scaledEnd) 1. If pot level is higher than LED indicator, write desired output to LED Useful Links Arduino Examples http://arduino.cc/en/Tutorial/HomePage MAKE projects http://makezine.com/arduino/ http://makezine.com/category/electronics/arduino/?post_type=pr ojects Adafruit ? Questions? Comments? Suggestions? academics@ieee.concordia.ca ieee.concordia.ca