Arduino LED Lab CTY SAR FCPS SHAWN LUPOLI

Arduino LED Lab CTY SAR FCPS SHAWN LUPOLI, ELLIOT TAN

Let’s learn a bit about the parts we will be using…

Ohm’s Law Voltage = Current * Resistance Voltage 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 (Ω) V = IR

Reading Resistors

Example Problems

For a quick answer http: //www. digikey. com/en/resources/conversion-calculators/conversioncalculator-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

Programming “Blink”

Overall Structure Global variables Void setup() { } 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

Blink: Part 1 Initializing global variables The LED will be connected to pin 13, so initialize a global variable “ int led = 13 “ Setup() pin. Mode(pin, mode) configures the pin to behave either as an input or an output Initialize the digital pin 13 as output using function

Blink: Part 2 Loop() Functions digital. Write(pin, disable voltage MODE) – HIGH enables voltage, LOW will delay(int x) – Pauses the program for the amount of time in milliseconds Examples digital. Write(13, Delay (1000) High);

CODE

Building the LED circuit

Supplies 1 Arduino board * Notes: 1 breadboard v Wires are 22 or 24 AWG, solid v Short wires = 5 cm v Medium wires = 12 cm v Long wires = 16 cm 4 long wires (one red, one black) 1 LED 1 resistors (330 kΩ)

Wiring the LED correctly

Diagram of LED circuit

Connecting Code and Circuit

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

Questions?
- Slides: 18