Purpose:
This lab will teach you how to control LED lights using buttons.
Equipment:
-2 push buttons
-1 330 ohm resistor
-2 10k ohm resistors
-1 LED
-1 wire (red)
-1 wire (black)
-4 wires (any colour)
-1 Arduino UNO
-1 breadboard
-1 USB cable
Program Details:
-Download Arduino here
Time to Program and Complete:
-Approximately 30 min
Results:
-There were some issues with spacing but after I fixed them it worked completely fine.
Photo/Video:
Program:
const int buttonPin = 2;
const int ledPin = 9;
int buttonState = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(buttonPin,INPUT);
}
void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}
Program Modifications:
-There were none; I followed all the instructions
Helpful Tips:
-Check spacing
-Check all the parts on the breadboard
References:
-Arduino website: arduino.cc
-New Innovators: Lab 3
No comments:
Post a Comment