Welcome to the World of Arduino
Alicia Trout, P.E.
Engineering & Technology Teacher
1
Physical
Computing
Building interactive systems using software and hardware that can sense and respond to the physical world.
2
Arduino Microcontroller
3
Circuit Components
4
Circuits
* Electricity travels from Power to Ground (the common or reference point in an electrical circuit - sometimes an actual physical connection with the ground)
Circuit: A circular journey or one beginning and ending at the same place
5
Lighting an LED
6
Soldering
7
A Semipermanent
connection.
What is a Breadboard?
8
A Closer
Look
9
BREADBOARD:
Using a Breadboard
10
ANALOG VS. DIGITAL
11
Arduino IDE
(Integrated Development Environment)
12
Arduino IDE: Bare Minimum
13
CODING TIPS
declare variables
reference libraries
void setup ()
{
all commands that you only need to do once;
}
void loop ()
{
all commands or functions that you want to repeat forever;
if (this statement is true)
{
do these commands in the curly brackets;
}
}
define functions
if (condition1) {
// do Thing A
}
else if (condition2) {
// do Thing B
}
else {
// do Thing C
}
Arduino IDE
15
Arduino IDE
16
Arduino IDE
17
Individual Arduino
Challenge Sign-off
18
Challenge: | Sign-off: |
1. Blink LED | |
2. 3 LED light show | |
3. LED with Photoresistor | |
4. RGB (Rainbow of colors) | |
5. One button (Example code) | |
6. Two Buttons (Challenge) | |
Name: __________________________________
Blinking LED
19
* We always use resistors between the Arduino and LEDs to keep the LEDs from burning out due to too much current. Use the 560 Ohm resistor (see next slide).
Wire the LED circuit as seen in the diagram below.
* Use a 560 Ohm resistor
Resistor Color Code
20
Multiple LEDs (Min of 3)
Create a little light show!
21
* Use 560 Ohm resistors
Wire at least 3 LEDs.
Modify the program to create a little light show.
* Show Mrs. Trout for sign-off.
Adding Input: photo Resistor
22
Use 10K Ohm resistor (with black & Orange stripe)
* Wire LED to pin 13.
* Wire Photoresistor to pin A0
Photoresistor
23
A photoresistor changes resistance based on how much light the sensor receives. The Arduino board measures voltage, not resistance, but our circuit will interpret the photoresistor resistance as voltage.
We will run a program to only turn on the LED while you’re holding your hand over (without touching) the photoresistor.
Hints:
* Show Mrs. Trout for sign-off.
if (condition1) {
// do Thing A
}
else {
// do Thing B
}
Photoresistor
24
Photoresistor
25
if (condition1) {
// do Thing A
}
else {
// do Thing B
}
RGB (Red green blue) LED
26
Use 560 Ohm resistors
Pin 9
Pin 10
Pin 11
27
RGB LED
This example starts with the RGB LED off and then turns on Red.
Modify the program to light up the following colors in this order:
RED�GREEN�BLUE�YELLOW�TURQUOISE�PURPLE
WHITE
Pin 9
Pin 10
Pin 11
const int RED_PIN = 9;
const int GREEN_PIN = 10;
const int BLUE_PIN = 11;
const int DISPLAY_TIME = 1000;
void setup()
{
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
}
void loop()
{
digitalWrite(RED_PIN, LOW);
digitalWrite(GREEN_PIN, LOW);
digitalWrite(BLUE_PIN, LOW);
delay(DISPLAY_TIME);
digitalWrite(RED_PIN, HIGH);
digitalWrite(GREEN_PIN, LOW);
digitalWrite(BLUE_PIN, LOW);
delay(DISPLAY_TIME);
}
Tips:
* Show Mrs. Trout for sign-off.
Buttons/Switches
Buttons
* Wire buttons to digital pins
2 & 3
* Power and GrounD to Column/Bus
* Use 10K Ohm PUll-down
Resistors (to negative/
Ground)
* blue/Yellow wires to positive
Program Buttons
Next step: Once you get your button to work, modify your program to have either button turn on the LED, and turn off the LED when both buttons are pressed together. Hint: Use Logical operators (shown in box above).
This program only uses one button (wired to pin 2). Leave both buttons wired for next step (bel0w).
Stop here and ask for next step...
31
32
Rover Track
33
Rover Build Instructions
34
Rover Build
35
36
37
38
A-1A: Pin 10
A-1B: Pin 9
B-1A: Pin 6
B-1B: Pin 5
39
40
Rover 1 | Rover 2 | Rover 3 | Rover 4 |
Grace | Logan | Divya | Sawyer |
| | | |
| | | |
| | | |
41
Rover 1 | Rover 2 | Rover 3 | Rover 4 |
Grace | Logan | Divya | Sawyer |
Jonah | Elias | Jake | Taylor |
| | | |
| | | |
42
Rover 1 | Rover 2 | Rover 3 | Rover 4 |
Grace | Logan | Divya | Sawyer |
Jonah | Elias | Jake | Taylor |
Rohan | Audrey | Tejas | Koe |
| | | Lily |
43
44
Stop here and ask for next step...
45
46
Challenge Sign-off
47
Challenge: | Sign-off: |
1. Blink LED (Heartbeat) | |
2. MUltiple LEDs (at least 3) | |
3. RGB - 7 COlors | |
4. LED with Photoresistor | |
5. Button with LED | |
6. LED with Potentiometer | |
7. Servo Motor | |
8. DC Motor | |
48
Refer to 7th Grade page of www.engtechclass.com for Individual Arduino Training Resources, which include basic coding to get you started on the circuits you will need to complete to receive sign-off.
Blinking LED
49
Open the “LED Blink” code.
You may either download the LEDBlink.ino file and then open it within the Arduino application
OR
Open the “LED Blink Arduino Code” Google Document and copy and paste the code into an Arduino sketch.
This example blinks an LED by turning on for 1 second (1000 milliseconds) and then turning off for 1 second (1000 milliseconds).
* To get signed off, adjust the timing to make the LED blink like a heartbeat.
RGB LED
50
Open the “RGB Starter” code.
This example starts with the RGB LED off and then turns on Red.
Modify the program to light up the following colors in this order:
RED�GREEN�BLUE�YELLOW�TURQUOISE�PURPLE
WHITE
* Show Mrs. Trout for sign-off.
Tips:
Photoresistor
51
Open the “Photoresistor” code.
A photoresistor changes resistance based on how much light the sensor receives. The Arduino board measures voltage, not resistance, but our circuit will interpret the photoresistor resistance as voltage.
The example program uses the value read by the photoresistor as the delay to blink the LED.
Modify the program to only turn on the LED while your holding your hand over (without touching) the photoresistor.
Hints:
* Show Mrs. Trout for sign-off.
if (condition1) {
// do Thing A
}
else {
// do Thing C
}
Servo Motor
52
Pay attention to how you attach your wires.
* Red wire is positive;
Brown wire is Negative
Servo MOtor
53
Open the “Servo Sweep” code.
Once you get your Servo Motor to work with the “Servo Sweep” program, modify your sketch to have your Servo motor go side to side like it is shaking it’s head to say “NO.”
* Show Mrs. Trout for sign-off.
DC Motor
54
Diode:
Match Direction
Diagram Key:
Green wire = Positive
Yellow wire = Negative wire
Use 560 Ohm
Transistor
DC MOtor
55
Open the “DC Motor” code.
Once you get your DC Motor to work, show Mrs. Trout that you can change the speed of the motor using the Serial Monitor (see next slide).
DC Motor
56
Serial Monitor
To Open Serial Monitor
Stop here and ask for next step...
57
Technology and Engineering Showcase
7 Work Days!!
58
Project Requirements
59
(ex: RGB, Photoresistor, Servo)
Submit a Video of your Project
60
machine.
Potentiometer
61
* 1oK: T103
Potentiometer
62
* Once you get your Potentiometer to work to adjust the Blinking speed of your LED, modify your circuit and program to adjust the intensity/brightness of your LED.
* Open this program from your folder on your Desktop (installed by Ms. Crump)
* Open
* From Desktop
* SIK Guide Code
LCD Screen
63
* Use the Autoscroll program and Change the text to something fun.
PLEAsE Refer to next slide for wiring your LCD Screen.
LCD Screen
64
LCD Screen
65
* Use the Autoscroll program and Change the text to something fun.
Circuit Components
Let’s make sure we have what you need to make your own complete Arduino set. Create an inventory in your journal.
66
Component (Quantity) | Image: |
UNO Microcontroller (1) | |
3’ USB Cable (1) | |
Tiny Breadboard (1) | |
10K Potentiometer (1) 1K Potentiometer (1) | |
Small Pushbutton (2) | |
Component (Quantity) | Image: |
Red Diffused LED (5) Red Ultra-Bright LED (1) Green Ultra-Bright LED (1) Blue Ultra-Bright LED (1) | |
100 Ohm Resistor (5) | |
1K Resistor (5) | |
10K Resistor (5) | |
Photocell Sensor (1) | |
DC Motor (1) | |
Servo Motor (1) | |
Wiring
Schematic
67
Arduino Individual Assessment
68
Arduino IDE: Bare Minimum
69
Arduino IDE
70