Top Banner
Microprocessors Tutorial 1: Arduino Basics
13

Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

Dec 13, 2015

Download

Documents

Cecilia Dennis
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

Microprocessors Tutorial 1:Arduino Basics

Page 2: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

Agenda

1. Arduino Hardware2. Arduino Software3. MAKE: Blink4. Electronics5. MAKE: LED control6. Analog7. MAKE: Volume control8. Links

Page 3: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

ATMega 328

6 Analog Pins

14 Digital Pins (6 PWM)

USB

Reset button

Power

Arduino Hardware

Page 4: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

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

Page 5: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

MAKE: BlinkUsing built in LED, so no further electronics needed!

1. Connect ArduinoWindows driver found?

Correct port?

2. Upload code

Page 6: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

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!

Page 7: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

MAKE: LED controlHardware1. Connect buses to bread board, 5v and GND2. Connect LED, pin->220ohm -> LED+ ->GND3. Connect button, 5v ->button ->10kohm ->GND

before res ->pin

Page 8: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

MAKE: LED controlSoftware1. Declare 2 pins outside and set direction in setup()2. Read button state3. If button is on, write desired output to LEDs

Software1. Declare 2 pins outside and set direction in setup()2. Read button state

Page 9: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

AnalogDigital: 0-1, On/Off LEDs, switches digitalRead(), digitalWrite()

Analog: 0-1023 Potentiometer, sensor, motors AnalogRead(), analogWrite()

Potentiometer: variable resistance

to pin

+5v

Page 10: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

MAKE: Volume IndicatorHardware1. Add more LEDs, each going to a different pin

2. Connect potentiometer, center connection to pin

Page 11: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

MAKE: Volume IndicatorSoftware1. Add LED pin variables and set direction2. Add pot pin, analog pin don't need direciton3. Get pot value4. Scale it using map(number, origStart, origEnd, scaledStart, scaledEnd)5. If pot level is higher than LED indicator, write desired output

to LED

Page 12: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

Useful Links

Arduino Examples http://arduino.cc/en/Tutorial/HomePage

MAKE projects http://makezine.com/arduino/http://makezine.com/category/electronics/arduino/?post_type=projects

Adafruit ?

Page 13: Microprocessors Tutorial 1: Arduino Basics. Agenda 1. Arduino Hardware 2. Arduino Software 3. MAKE: Blink 4. Electronics 5. MAKE: LED control 6. Analog.

[email protected]

Questions? Comments? Suggestions?