//Turn on LED and Relay using Arduino controlled by a button //define the pin constants int ledPin = 22; int button = 23; int relay = 24; void setup(){ //set the led pin to output pinMode(ledPin, OUTPUT); //set the button to input pinMode(button, INPUT); //set the relay to output pinMode(relay, OUTPUT); } void loop(){ //read and store the button state boolean State = digitalRead(button); //set the led to the button state digitalWrite(ledPin,State); //set the relay to the button state digitalWrite(relay,State); }