gabbyshimoni icon

rainbow RGB Led

gabbyshimoni | PRO | 02/03/19 07:27:50 AM UTC | 0 ⭐ | 711 👁️ | Never ⏰ | []
C++ |

1 KB

|

None

|

0 👍

/

0 👎

/*
   03.02.2019
   Written by: Gabby Shimoni
   Description:
   This program makes and RGB led shine with rainbow colors
 
   Color Description RGB Values
   Violet            148, 0, 211
   Indigo             75, 0, 130
   Blue                0, 0, 255
   Green               0, 255, 0
   Yellow            255, 255, 0
   Orange            255, 127, 0
   Red               255, 0 , 0
*/
 
const int rgbLedPins[3] = {9, 11, 10}; // The pin numbers are : R B G
int rainbow[7][3] = {
  148, 0, 211,
  75, 0, 130,
  0, 0, 255,
  0, 255, 0,
  255, 255, 0,
  255, 127, 0,
  255, 0 , 0
};
String colors[7] = {"Violet", "Indigo", "Blue", "Green", "Yellow", "Orange", "Red"};
void setup() {
  Serial.begin(9600);
  for (int i = 0; i < 3; i++) pinMode(rgbLedPins[i], OUTPUT);
}
 
void loop() {
  for (int i = 0; i < 7; i++) {
    for (int j = 0; j < 3; j++) {
      analogWrite(rgbLedPins[j], rainbow[i][j]);
    }
    Serial.print(colors[i]);
    Serial.println(" is on");
    delay(3000);
  }
}

Comments