const int switch1 = 5; //declare switch button pins
const int switch2 = 4;
void setup() {
pinMode(switch1, INPUT); // set switch pins to input
pinMode(switch2, INPUT);
Serial.begin(9600); // begin serial communication at 9600 bps
}
void loop() {
byte msg = digitalRead(switch2); //declare variable "msg" and set it to the value of digitalRead(switch1) (returns 1 if button is pushed, 0 if not
msg = msg<<1; //shift bits left (ex. 0000 0001 becomes 0000 0010)
msg = msg | digitalRead(switch1); //use bitwise OR to combine the 2 (ex. 0000 0010 | 0000 0001 = 0000 0011)
Serial.print(msg); //prints 0 if neither are pressed, 3 if both, 2 for just switch2 and 1 for just switch1
delay(100); //waits 1/10 second
}