LED Status Lights

For this project we’ll connect up the LED Module and turn the built in LED on when it is pressed. For the simplest version of this project, you’ll use the HW-479 (Push) Button Module and 3 wires. Once you see it working, you can modify it so that you use the power rails on the breadboard. That will make it easier to integrate this setup with other projects.

// Sketch for HW-479 
// Component: https://www.iotprojectkit.com/components/hw-479-rgb-led-module/
// Tutorial: https://www.iotprojectkit.com/led-status-lights/

// Change to the pin number that the Button module "S" pin is connected to
#define RED_PIN 11
#define GREEN_PIN 12
#define BLUE_PIN 13

void setup() {
  pinMode(RED_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(BLUE_PIN, HIGH);
  delay(500);
  digitalWrite(BLUE_PIN, LOW);
  delay(100); 
  digitalWrite(GREEN_PIN, HIGH);  
  delay(500);  
  digitalWrite(GREEN_PIN, LOW);  
  delay(100); 
  digitalWrite(RED_PIN, HIGH);  
  delay(500);  
  digitalWrite(RED_PIN, LOW);  
  delay(10000); 
}

You can combine the schematic from this project with the Button Press project to build the State Machine project.