Simple RGB LED with CloudX CloudX

  • img
Project Details

This project is using a common anode RGB LED, so the longest pin of the LED is connected to 5V, whereas the three other pins are connected to three CloudX pins directly but you can still decide to put a resistor 220ohms each of them. The first pin (left of the longest one) is controlling the Red LED, the third pin is controlling the Green LED and the last one is controlling the blue LED.

Pushbuttons require a normal wiring with one side connected to GND, the other side connected to 5v with a 10K ohm resistor and a cloudx pin connected to the line where the button is connected to 5v. You can also watch project video on YouTube.

 

 

Code

/* RGB LED push button project using M633 */

#define bluePin  1
#define greenPin  2
#define redPin  3

#define buttonPin1 4
#define buttonPin2 5
#define buttonPin3 6

setup(){
//setup here

//configure all the LED pins as Output
pinMode(bluePin, OUTPUT);
pinMode(greenPin,OUTPUT);
pinMode(redPin,  OUTPUT);

//Configure all the button pins as Input
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);

//Each LED pins need LOW to come on
digitalWrite(bluePin, HIGH);
digitalWrite(greenPin, HIGH);
digitalWrite(redPin, HIGH);

loop(){
//Program here

//Check if button 1 is pressed
if(digitalRead(buttonPin1) == LOW)
{
digitalWrite(greenPin, HIGH);
digitalWrite(redPin, HIGH);
digitalWrite(bluePin, LOW);
delay(100);
}

//Check if button 2 is pressed
if(digitalRead(buttonPin2) == LOW)
{
digitalWrite(bluePin, HIGH);
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, LOW);
delay(100);
}

//Check if button 3 is pressed
if(digitalRead(buttonPin3) == LOW)
{
digitalWrite(bluePin, HIGH);
digitalWrite(greenPin, HIGH);
digitalWrite(redPin, LOW);
delay(100);
}
}
}
 

 

PROJECT TESTING

Share this with friends