Assignment 10A
PushButton.
In Action:
My Code:
const int buttonPin1 = 2;
const int buttonPin2 = 3;
const int ledPin = 9;
int buttonState1 = 0;
int buttonState2 = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
}
void loop(){
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
int value = 0;
if (buttonState1 == HIGH) {
Serial.println("1");
value += 100;
}
if (buttonState2 == HIGH) {
Serial.println("2");
value += 100;
}
analogWrite(ledPin, value);
delay(15);
}