Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int y,counter,redVal,greenVal,blueVal;
- int RGB[2];
- void setup() {
- randomSeed(analogRead(A1));
- Serial.begin(9600);
- }
- void loop() {
- // y = random(765);
- for(int x=255;x>=0;x--){
- analogWrite(9, getColor(RGB[0]));
- analogWrite(10, getColor(RGB[1]));
- analogWrite(11, getColor(RGB[2]));
- counter = x * 3;
- RGB[0] = counter;
- RGB[2] = (counter + 255) % 765;
- RGB[1] = (RGB[2] + 255) % 765;
- delay(10);
- }
- }
- int getColor(int x){
- int phase = x / 255;
- int mod = x % 255;
- if (phase == 0){
- return 0;
- }
- if(phase == 1){
- return mod;
- }
- if(phase == 2){
- return 255 - mod;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement