Niko123
Published © GPL3+

RGB LED

A basic code and schematic to light an RGB LED.

BeginnerShowcase (no instructions)594
RGB LED

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
RGB Diffused Common Cathode
RGB Diffused Common Cathode
×1
Resistor 221 ohm
Resistor 221 ohm
×3

Schematics

SCHEMATIC

Code

SOFTWARE

C/C++
#define redpin 11 // RED
#define greenpin 10 // GREEN
#define bluepin 6 // BLUE
void setup() {
  pinMode(redpin, OUTPUT);
  pinMode(greenpin, OUTPUT);
  pinMode(bluepin, OUTPUT);
  }
void loop() {
  
//RED
  analogWrite(redpin, 225);
  analogWrite(greenpin, 0);
  analogWrite(bluepin, 0);
  delay(2000);
  //GREEN
  analogWrite(redpin, 0);
  analogWrite(greenpin, 225);
  analogWrite(bluepin, 0);
  delay(2000);
  //BLUE
  analogWrite(redpin, 0);
  analogWrite(greenpin, 0);
  analogWrite(bluepin, 225);
  delay(2000);
}

Credits

Niko123
3 projects • 10 followers
Contact

Comments

Please log in or sign up to comment.