Advertisement
ossipee

attiny_45_bling

Apr 14th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1.    /*
  2.     ATTINY 45 RGB LED FOR THE BLING THING
  3.     */
  4.      
  5.     int redPin = 0;
  6.     int greenPin = 1;
  7.     int bluePin = 3;
  8.      
  9.     void setup()
  10.     {
  11.     pinMode(redPin, OUTPUT);
  12.     pinMode(greenPin, OUTPUT);
  13.     pinMode(bluePin, OUTPUT);
  14.     }
  15.      
  16.     void loop()
  17.     {
  18.     setColor(255, 0, 0); // red
  19.     delay(1000);
  20.     setColor(0, 255, 0); // green
  21.     delay(1000);
  22.     setColor(0, 0, 255); // blue
  23.     delay(1000);
  24.     setColor(255, 255, 0); // yellow
  25.     delay(1000);
  26.     setColor(128, 0, 128); // purple
  27.     delay(1000);
  28.     setColor(0, 255, 255); // aqua
  29.     delay(1000);
  30.     setColor(128, 128, 0); //olive
  31.     delay(1000);
  32.     setColor(0, 128, 128); //teal
  33.     delay(1000);
  34.     }
  35.      
  36.     void setColor(int red, int green, int blue)
  37.     {
  38.     analogWrite(redPin, red);
  39.     analogWrite(greenPin, green);
  40.     analogWrite(bluePin, blue);
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement