Lesson 2

Goal

Todays project will involve connecting 2 LEDs to our Arduino (don't forget the resistors!) and making them flash.

Each LED will be connected to its own digital pin, through a resistor and finally to a ground pin.

Both LEDs can go to the same ground pin but they MUST be connected to their own digital pin. (pins 10 and 16 in the example)

New Arduino Functions


pinMode(pinNumber, mode)

Sets a digital pin to either OUTPUT or INPUT mode. To send a current through the pin and light our LED we need to set the pinNumber of the pin we are using and set the mode to OUTPUT. INPUT is used when we want the pin to receive a signal.

Should usually only be set one time in the setup(){} block.


digitalWrite(pinNumber, mode)

Sets a digital pin to either on or off (5 volts). Set the pin mode to HIGH to turn it on and LOW to turn it off.


delay(milliseconds)

Forces the Arduino to wait for however many milliseconds. The Arduino will not read the next line of code until the time has passed. 1000 milliseconds = 1 second.

Schematic

PseudoCode

Code

Homework