- Start in Tinkercad and build this program and circuit
- Then build your circuit with a real Arduino and breadboard.
Use the diagram below to add a button to your circuit. Pay close attention to the types of resistors (look at the colored stripes). - When you are done, turn in two items on Canvas:
1. turn in the link to your Tinkercad program with four LEDS, a button and serial monitor by following these instructions.
2. record a short video of your REAL LIFE circuit working.
What you need:
one 220 resistor for each LED
one 220 resistor for the button AND one 10k resistor for the button
a button
sample code to get you started – at the bottom of this assignment
Color code:
red wires- leading from pins to breadboard
black wires- ground
green wires- button
yellow wires – input from pin 2
After you have built your sample program with ONE LED DO THIS:
-add to your program and circuit so that there are four LEDs that are triggered when the button is pressed.
-add serial monitor commands to your program so that is shows WHEN the button is pressed.
Now here’s the sample code – copy and paste what’s below this into a brand new Arduino file:
int red = 13;
int button = 2;
void setup()
{
pinMode(red, OUTPUT);
pinMode(button, INPUT);
Serial.begin(9600);
}
void loop()
{
if(digitalRead(button) == HIGH)
{
Serial.println(“button pressed”);
digitalWrite (red, HIGH);
delay (500);
digitalWrite(red,LOW);
delay (500);
digitalWrite (red, HIGH);
delay (500);
digitalWrite(red,LOW);
delay (500);
}
else
{
digitalWrite(red, HIGH);
}
}