To carry out this simple tutorial 5, below are the items you need alongside your computer with an arduino program already installed.
1. Arduino UNO board
2. Breadboard
3. Malemale connection cables
4. A 330Ω resistors (orange, orange, brown)
5. A 10kΩ resistor (brown, black, orange)
6. One red LED
7. One push/button
Below is the program for this tutorial 5:
//Constant declaration
#define LED 12 // Pin to which the red LED is connected
#define BUTTON 2 // Pin to which the push button is connected
//Pin configurations
void setup ()
{
pinMode (LED, OUTPUT);
pinMode (BUTTON, INPUT);
digitalWrite (LED, LOW);
}
void loop ()
{
//Depending on the value read from the button, the LED turns on or off
if (digitalRead (BUTTON) == LOW)
digitalWrite (LED, HIGH);
else
digitalWrite (LED, LOW);
}
Enjoy and subscribe!!