Pumpkin code

// color changer plus flashing white for pumpkin color
// adjust the 5k pot to set max flash brightness
// code written for ATtiny84 with Arduino bootloader
// eositis 19 oct 2013

float RGB1[2];
float RGB2[2];
float INC[2];
int red, white, blue;
int redpin = 6;
int bluepin = 7;
int whitepin = 8;
int whitepot = 4;
int whitemax;

void setup() {
  randomSeed(analogRead(0));
  RGB1[0] = 0;
  RGB1[1] = 0;
  RGB2[0] = random(256);
  RGB2[1] = random(256);
}

void loop() {
  randomSeed(analogRead(0));
  whitemax = analogRead(whitepot)/5;
  for (int x=0; x<2; x++) {
    INC[x] = (RGB1[x] - RGB2[x]) / 256; }
  for (int x=0; x<256; x++) {
    red = int(RGB1[0]);
    blue = int(RGB1[1]);
    analogWrite (redpin, red);
    analogWrite (bluepin, blue);
    delay(30);
    RGB1[0] -= INC[0];
    RGB1[1] -= INC[1];
    analogWrite(whitepin, random(whitemax));
  }
  for (int x=0; x<2; x++) {
    RGB2[x] = random(356)-100;
    RGB2[x] = constrain(RGB2[x], 0, 255);
    delay(75);
  }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s