The logical and operator in C is '&&' not 'and'
Also, unless you have external pullup resistors connected to your buttons, you want to declare them as INPUT_PULLUP, not INPUT.
//Initialize Variables
const int ledPin = 5; // choose the pin for the LED
const int ledPin2 = 6;
const int ledPin3 = 7;
const int inPin = 2; // pin for button 1
const int inPin2 = 3; // pin for button 2
const int inPin3 = 4; // pin for button 3
void setup()
{
Serial.begin(9600);
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inPin, INPUT_PULLUP); // declare pushbutton as input
pinMode(ledPin2, OUTPUT); // declare LED as output
pinMode(inPin2, INPUT_PULLUP); // declare pushbutton as input
pinMode(ledPin3, OUTPUT); // declare LED as output
pinMode(inPin3, INPUT_PULLUP); // declare pushbutton as input
}
void loop()
{
//Read button output
int val1 = digitalRead(inPin); // read input value
int val2 = digitalRead(inPin2); // read input value
int val3 = digitalRead(inPin3);
if (val1 == HIGH)
{ // check if the input is HIGH (button released)
digitalWrite(ledPin, LOW); // turn LED OFF
} else
{
digitalWrite(ledPin, HIGH); // turn LED ON
}
if (val2 == HIGH)
{ // check if the input is HIGH (button released)
digitalWrite(ledPin2, LOW); // turn LED OFF
} else
{
digitalWrite(ledPin2, HIGH); // turn LED ON
}
// read input value
if (val3 == HIGH && val1 == HIGH)
{ // check if the input is HIGH (button released)
digitalWrite(ledPin3, LOW); // turn LED OFF
}
else
{
digitalWrite(ledPin2, HIGH);// turn LED ON
digitalWrite(ledPin, HIGH);
}
}