/*
Attempt to make a circuit design.
Idea is - push button and led lights
If button is lit, then turn led off.
/
Button is attached to the 5V and a 220 Ohm resistor to ground
Top of button is attached to pin 2 (input)
Led anode is attached to output pin 8
Led cathode is attached to 220 Ohm resistor to ground
*/
// Set constants and variables
const int buttonPin = 2;
const int ledPin = 8;
int buttonState = 0;
void setup() {
// intialize pins and ensure LED is off
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
}
void loop() {
// Read state of button
if (buttonState == HIGH) {
digitalWrite(ledPin, LOW);
} else {
digitalWrite(ledPin, HIGH);
}
}