int buttonValue; //introduce variable
void setup() {
Serial.begin(9600); //begin serial communication
pinMode(7,INPUT); //pin 7 is an input
pinMode(9, OUTPUT); //pin 9 is an output
}
void loop() {
buttonValue=digitalRead(7); //read from pin 7 and store it to buttonValue
Serial.println(buttonValue); //print that value
if(buttonValue==1) //check if value is equal to 1
{
digitalWrite(9,HIGH); //if so send high signal to pin 9
}
else
{
digitalWrite(9,LOW); //if not turn it to low signal
}
}