SHARE
TWEET

RGB StripLight Color Swirl Test Code

w0lfiesmith Dec 6th, 2012 1,897 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define REDPIN 9
  2. #define GREENPIN 11
  3. #define BLUEPIN 10
  4.  
  5. #define FADESPEED 5     // make this higher to slow down
  6.  
  7. void setup() {
  8.   pinMode(REDPIN, OUTPUT);
  9.   pinMode(GREENPIN, OUTPUT);
  10.   pinMode(BLUEPIN, OUTPUT);
  11. }
  12.  
  13.  
  14. void loop() {
  15.   int r, g, b;
  16.  
  17.   // fade from blue to violet
  18.   for (r = 0; r < 256; r++) {
  19.     analogWrite(REDPIN, r);
  20.     delay(FADESPEED);
  21.   }
  22.   // fade from violet to red
  23.   for (b = 255; b > 0; b--) {
  24.     analogWrite(BLUEPIN, b);
  25.     delay(FADESPEED);
  26.   }
  27.   // fade from red to yellow
  28.   for (g = 0; g < 256; g++) {
  29.     analogWrite(GREENPIN, g);
  30.     delay(FADESPEED);
  31.   }
  32.   // fade from yellow to green
  33.   for (r = 255; r > 0; r--) {
  34.     analogWrite(REDPIN, r);
  35.     delay(FADESPEED);
  36.   }
  37.   // fade from green to teal
  38.   for (b = 0; b < 256; b++) {
  39.     analogWrite(BLUEPIN, b);
  40.     delay(FADESPEED);
  41.   }
  42.   // fade from teal to blue
  43.   for (g = 255; g > 0; g--) {
  44.     analogWrite(GREENPIN, g);
  45.     delay(FADESPEED);
  46.   }
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top