Zhenxuan’s Arduino Homework2

// constants won’t change. They’re used here to set pin numbers:
const int onbutton = 2; // the number of the pushbutton pin
const int offbutton = 3;
const int jeremy = 13; // the number of the LED pin

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

void setup() {
// initialize the LED pin as an output:
pinMode(jeremy, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(onbutton, INPUT);
pinMode(offbutton, INPUT);
}

void loop() {
// read the state of the pushbutton value:
whatisit = digitalRead(onbutton);
if (whatisit == 1) {
// turn LED on:
digitalWrite(jeremy, HIGH);
}
whatisit = digitalRead(offbutton);
if (whatisit == 1) {
digitalWrite(jeremy, LOW);
}

}