Pushing my buttons

Here is how it went down:

Code for the last one:

// set pin numbers:
const int LightOn = 2; // the number of the pushbutton pin
const int LightOff = 9;
const int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pins as an input:
pinMode(LightOn, INPUT);
pinMode(LightOff, INPUT);
void loop(){
if (digitalRead(LightOff) == LOW) {
digitalWrite(ledPin, LOW); //this turns the LED off
} else if (digitalRead(LightOn) == LOW) {
digitalWrite(ledPin, HIGH); // this turns the LED on

One thought on “Pushing my buttons”

Comments are closed.