Download presentation
Presentation is loading. Please wait.
1
CTY SAR FCPS Shawn Lupoli, Elliot Tan
Arduino LED Lab CTY SAR FCPS Shawn Lupoli, Elliot Tan
2
Let’s learn a bit about the parts we will be using…
3
Ohm’s Law Voltage = Current * Resistance V = IR Voltage Current
Electric potential difference Measured in Volts (V) Current Flow of electric charge Measured in Amperes (I) Resistance Conductor’s opposition to passage of electric current Measured in Ohms (Ω)
4
Reading Resistors
5
Example Problems
6
For a quick answer calculators/conversion-calculator-resistor-color-code-4-band Make sure to select how many colored bands there are on the resistor If the URL has changed, please let your instructional staff know
7
Programming “Blink”
8
Overall Structure Global variables Void setup() { } Void loop() { }
This function is called when a sketch starts Used to initialize variables, pin modes, and start using library Will only run once Void loop() { } Loops consecutively Allows your program to change and respond
9
Blink: Part 1 Initializing global variables Setup()
The LED will be connected to pin 13, so initialize a global variable “ int led = 13 “ Setup() pinMode(pin, mode) configures the pin to behave either as an input or an output Initialize the digital pin 13 as output using function
10
Blink: Part 2 Loop() Functions Examples
digitalWrite(pin, MODE) – HIGH enables voltage, LOW will disable voltage delay(int x) – Pauses the program for the amount of time in milliseconds Examples digitalWrite(13, High); Delay (1000)
11
CODE
12
Building the LED circuit
13
Supplies 1 Arduino board 1 breadboard
4 long wires (one red, one black) 1 LED 1 resistors (330 kΩ) * Notes: Wires are 22 or 24 AWG, solid Short wires = 5 cm Medium wires = 12 cm Long wires = 16 cm
14
Wiring the LED correctly
15
Diagram of LED circuit
16
Connecting Code and Circuit
17
Putting it All Together
UPLOAD! Remember to check for the flashing RX and TX lights, and a “Successful upload” message in your console Understanding the process Since pin 13 is initialized as output, your computer tells the circuit what the do through pin 13 Turning on the LED, waiting, turning off the LED, waiting The switches will open and close the circuit, allowing the LEDs to either blink or not blink
18
Questions?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.