week_2: switches & LED circuits


Here I describe the implementation of the fist projects included on the Arduino's companion booklet as concrete examples of the topics learned and discussed in class during the second week. I familiarized myself with first concepts of electricity and electronics, physical computing and the Arduino platform. I ordered the supporting tools and parts needed to work as well. In addition to the Arduino starter kit, I also obtained the Adafruit's starter kit as complementary material.



Interactive circuit, using a switch, a resistor, and an LED




A resistor (220 ohm) is in series with an LED, with a momentary switch (pushbutton) controlling the flow of electricity. The Arduino and the circuit are powered through the USB port connected to my laptop computer.



Two switches in series


 Both switches need to be pressed to allow for the flow of current through the LED 




Two switches in parallel



When either switch is pressed, the circuit is completed and current flows through the LED, turning the light on




Using software to program the behavior of hardware


In this implementation, I modified the Arduino sketch described in pages 37 to 39 from the Arduino's Projects Book. The modifications resulted in the following code:



int switchState = 0;


void setup() {


pinMode(3, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);


pinMode(2, INPUT);




void loop() {


switchState = digitalRead(2);


if (switchState == LOW) {

 digitalWrite(3, LOW);




 digitalWrite(4, HIGH);

 digitalWrite(5, HIGH);



else {

digitalWrite(3, HIGH);

digitalWrite(4, LOW);

digitalWrite(5, HIGH);




digitalWrite(4, HIGH);

digitalWrite(5, LOW);








The successful implementation of the above code guided the behavior of the following circuit configuration:








The Arduino Project Book (2015). Published by Arduino LLC










Please reload

New York, United States