// constants won't change. // set pin numbers: const int buttonPin = 0; // the number of the pushbutton pin const int redPin = 2; // the number of the LED pin const int greenPin = 3; // the number of the LED pin const int bluePin = 4; // the number of the LED pin // initialize variables: int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize input/OUTPUT: pinMode(buttonPin, INPUT); pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); } void loop(){ // read the state of the pin the pushbutton is connected to: buttonState = digitalRead(buttonPin); // is the push button pressed? // if not pressed - the button state is HIGH // the pull up resistor the button / pin 3 makes the button state HIGH by default. if (buttonState == 1) { // turn LED off (LED is off by default) digitalWrite(redPin, 255); digitalWrite(greenPin, 255); digitalWrite(bluePin, 255); } //otherwise..... // button is pressed else { // turn LED on: digitalWrite(redPin, 255); digitalWrite(greenPin, 255); digitalWrite(bluePin, 0); } }