My tail schematics (SCRAP)
This is for Rev1 without the extra transmitter. I plan to redo with neopixels they are are easier to control and many more paturns can be achieved without loosing brightness.
Multiplexing is a cheap way to make LEDs to allot of stuff with an Arduino!
My "Sketch" below:
/*
Dennis Liang
© Drakes Computers
LED driver controler, 10 wires.
RGB
1,2,3,4,5,6,7
*/
#include <EEPROM.h>
#include <VirtualWire.h>
byte left_blade =10;
byte right_blade =12;
byte first_spike =A2;
byte second_spike = A0;
byte third_spike = A3;
byte forth_spike = A1;
byte fifth_spike = 11;
byte red_pin = 6;
byte green_pin = 5;
byte blue_pin = 3;
boolean disable_power= false;
byte mode = 0;
byte color_red = 100;
byte color_green = 100;
byte color_blue = 100;
#define mode_address 1
#define pwr_address 0
#define red_address 2
#define green_address 3
#define blue_address 4
const byte tx_1_pin = 7;
const byte tx_2_pin = 8;
const byte tx_3_pin = 9;
void setup() {
// nothing happens in setup
//pinMode(10,OUTPUT);
//digitalWrite(10,HIGH);
Serial.begin(115200);
Serial.print(F("$$$"));
delay(100);
Serial.println(F("SN,DrakeTail"));
delay(100);
Serial.println(F("SM,0"));
delay(100);
Serial.println(F("---"));
//Configure Transmitter
pinMode(tx_1_pin,OUTPUT);
pinMode(tx_2_pin,OUTPUT);
pinMode(tx_3_pin,OUTPUT); //VCC pin
digitalWrite(tx_1_pin, LOW);
digitalWrite(tx_3_pin, HIGH);
vw_set_tx_pin(tx_2_pin);
vw_setup(1000);
//Done configuring transmitter
pinMode(red_pin,OUTPUT);
pinMode(green_pin,OUTPUT);
pinMode(blue_pin,OUTPUT);
pinMode(left_blade,INPUT); //left blade
pinMode(fifth_spike,INPUT); //5th spike
pinMode(right_blade,INPUT); //Right blade
pinMode(third_spike,INPUT); //3rd spike
pinMode(second_spike,INPUT); //2nd spike
pinMode(forth_spike,INPUT); //4th spike
pinMode(first_spike,INPUT); //1st spike
randomSeed(analogRead(7)); //initilize the randomizer
mode = EEPROM.read(mode_address); //restore mode
if (EEPROM.read(pwr_address) == 1) //restore power
disable_power = true;
//restore color setting
if (EEPROM.read(red_address) > 100)
color_red = 100;
else
color_red = EEPROM.read(red_address);
if (EEPROM.read(green_address) > 100)
color_green = 100;
else
color_green = EEPROM.read(green_address);
if (EEPROM.read(blue_address) > 100)
color_blue = 100;
else
color_blue = EEPROM.read(red_address);
delay(5000);
while(Serial.available() > 0)
Serial.read();
//Serial.setTimeout(3000);
Serial.print(F("Tail Light controller\r\n©2013 Drakes Computers,\r\nCompiled on\r\n"));
Serial.println(F(__DATE__));
Serial.println(F(__TIME__));
Serial.println(F("Ready."));
}
void loop() {
menu(); ///drive on screen menu
if (!disable_power)
switch (mode)
{
case 0:
light_spike((byte)random(0, 7), (byte)random(0, 100), (byte)random(0, 100), (byte)random(0, 100), 1);
break;
case 1:
down_strobe();
break;
case 2:
up_strobe();
break;
case 3:
ping_pong();
break;
case 4:
//Mode used to switch LEDS on and off?
break;
}
//menu area
}
void down_strobe()
{
static int led_position;
//static unsigned long previousMillis;
//if(millis() - previousMillis > 100) {
// save the last time you blinked the LED
// previousMillis = millis();
light_spike(led_position, color_red, color_green, color_blue, 1); //Change LED position
led_position--;
//}
if (led_position < 0)
led_position = 6;
}
void up_strobe()
{
static int led_position;
//static unsigned long previousMillis;
//if(millis() - previousMillis > 100) {
// save the last time you blinked the LED
// previousMillis = millis();
light_spike(led_position, color_red, color_green, color_blue, 1); //Change LED position
led_position++;
//}
if (led_position > 7)
led_position = 0;
}
void ping_pong()
{
static int led_position;
static boolean led_direction; //goes in reverse
//static unsigned long previousMillis;
//if(millis() - previousMillis > 100) {
// save the last time you blinked the LED
// previousMillis = millis();
light_spike(led_position, color_red, color_green, color_blue, 1); //Change LED position
if (led_direction)
led_position--;
else
led_position++;
//}
if (led_position > 7)
led_direction = true;
if (led_position < 0)
led_direction = false;
}
void menu()
{
int parseint_color = 0;
if (Serial.available() > 0) {
byte serialbyte = Serial.read();
switch (serialbyte) {
case '0': //Changes lighting modes
mode = 0;
Serial.println(F("Mode:0 Random lights and colors"));
EEPROM.write(mode_address,mode);
sendtohead('0');
break;
case '1':
mode = 1;
Serial.println(F("Mode:1 Strobe up"));
EEPROM.write(mode_address,mode);
sendtohead('1');
break;
case '2':
mode = 2;
Serial.println(F("Mode:2 Strobe down"));
EEPROM.write(mode_address,mode);
sendtohead('2');
break;
case '3':
mode = 3; //***********************
Serial.println(F("Mode:3 Ping pong"));
EEPROM.write(mode_address,mode);
sendtohead('3');
break;
/*case '4':
mode = 4; //***********************
Serial.println(F("Mode:4 Manual"));
EEPROM.write(mode_address,mode);
break;
*/
case 'Q':
case 'q':
color_red++;
if (color_red > 100)
color_red = 100;
Serial.print(F("Color_red:")); Serial.println(color_red,DEC);
sendtohead('r',color_red + 1);
break;
case 'W':
case 'w':
color_green++;
if (color_green > 100)
color_green = 100;
Serial.print(F("Color_green:")); Serial.println(color_green,DEC);
sendtohead('g',color_green + 1);
break;
case 'E':
case 'e':
color_blue++;
if (color_blue > 100)
color_blue = 100;
Serial.print(F("Color_blue:")); Serial.println(color_blue,DEC);
sendtohead('b',color_blue + 1);
break;
case 'A':
case 'a':
color_red--;
if (color_red > 100)
color_red = 0; //using wrap around
Serial.print(F("Color_red:")); Serial.println(color_red,DEC);
sendtohead('r',color_red + 1);
break;
case 'S':
case 's':
color_green--;
if (color_green > 100)
color_green = 0; //using wrap around
Serial.print(F("Color_green:")); Serial.println(color_green,DEC);
sendtohead('g',color_green + 1);
break;
case 'D':
case 'd':
color_blue--;
if (color_blue > 100)
color_blue = 0; //using wrap around
Serial.print(F("Color_blue:")); Serial.println(color_blue,DEC);
sendtohead('b',color_blue + 1);
break;
case 'R':
case 'r':
Serial.print(F("RED:\nEnter number(1-101):"));
parseint_color = Serial.parseInt();
if (parseint_color > 0)
color_red = parseint_color-1;
Serial.println(parseint_color,DEC);
sendtohead('r',parseint_color);
break;
case 'G':
case 'g':
Serial.print(F("GREEN:\nEnter number(1-101):"));
parseint_color = Serial.parseInt();
if (parseint_color > 0)
color_green = parseint_color-1;
Serial.println(parseint_color,DEC);
sendtohead('g',parseint_color);
break;
case 'B':
case 'b':
Serial.print(F("BLUE:\nEnter number(1-101):"));
parseint_color = Serial.parseInt();
if (parseint_color > 0)
color_blue = parseint_color-1;
Serial.println(parseint_color,DEC);
sendtohead('b',parseint_color);
break;
case 'p':
case 'P':
Serial.println(F("LED's on!"));
disable_power = false;
EEPROM.write(pwr_address,(byte)disable_power);
sendtohead('p');
break;
case 'O':
case 'o':
Serial.println(F("LED's off!"));
disable_power = true;
EEPROM.write(pwr_address,(byte)disable_power);
sendtohead('o');
break;
case 'f':
case 'F':
Serial.println(F("FAN's on!"));
sendtohead('f');
break;
case 'v':
case 'V':
Serial.println(F("FAN's off!"));
sendtohead('v');
break;
case 'C':
case 'c':
EEPROM.write(red_address,color_red);
EEPROM.write(green_address,color_green);
EEPROM.write(blue_address,color_blue);
Serial.println(F("Settings Saved!"));
break;
case 'L':
case 'l':
Serial.print("SETTINGS:");
Serial.print(mode, DEC);
Serial.print(",");
Serial.print(color_red+1, DEC);
Serial.print(",");
Serial.print(color_green+1, DEC);
Serial.print(",");
Serial.print(color_blue+1, DEC);
Serial.println(".");
break;
//main menu
case '?':
case 'h':
case '\r':
Serial.println(F("*******************"));
Serial.println(F("Available Commands:"));
Serial.println(F("p-Power On"));
Serial.println(F("o-Power Off"));
Serial.println(F("0-Random Flicker"));
Serial.println(F("1-Stobe Up"));
Serial.println(F("2-Stobe Down"));
Serial.println(F("3-Ping Pong"));
//Serial.println(F("4-Manual"));
Serial.println(F("f-FAN ON"));
Serial.println(F("v-FAN OFF"));
Serial.println(F("q-RED++"));
Serial.println(F("w-GREEN++"));
Serial.println(F("e-BLUE++"));
Serial.println(F("a-RED--"));
Serial.println(F("s-GREEN--"));
Serial.println(F("d-BLUE--"));
Serial.println(F("r-RED, set"));
Serial.println(F("g-GREEN, set"));
Serial.println(F("b-BLUE, set"));
Serial.println(F("c-Save color changes."));
Serial.println(F("l-Get settings"));
Serial.print(F("Power:"));
if (disable_power)
Serial.println(F("OFF!"));
else
Serial.println(F("ON!"));
Serial.print(F("Mode:"));
Serial.println(mode,DEC);
Serial.print(F("COLOR:"));
Serial.print(color_red+1, DEC);
Serial.print(",");
Serial.print(color_green+1, DEC);
Serial.print(",");
Serial.print(color_blue+1, DEC);
Serial.println(".");
// Serial.println(F("S-Scan for signal"));
}
//
} //serial port
}
//void fade()
//{
//
// // fade in from min to max in increments of 5 points:
// for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// // sets the value (range from 0 to 255):
// analogWrite(6, fadeValue); //Red
// analogWrite(3, fadeValue);
// analogWrite(5, fadeValue);
// // wait for 30 milliseconds to see the dimming effect
// delay(1);
// }
//
// // fade out from max to min in increments of 5 points:
// for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// // sets the value (range from 0 to 255):
// analogWrite(6, fadeValue);
// analogWrite(3, fadeValue);
// analogWrite(5, fadeValue);
// // wait for 30 milliseconds to see the dimming effect
// delay(1);
// }
//}
void pulsecolor(byte red, byte green, byte blue, int time)
{
/*
Pulse to that color. Pulse time depends on time x color steps
*/
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(red_pin, fadeValue * red / 100); //Red
analogWrite(green_pin, fadeValue * green / 100); //Green
analogWrite(blue_pin, fadeValue * blue / 100); //Blue
// wait for 30 milliseconds to see the dimming effect
// Serial.print("Fading value:");
// Serial.println(fadeValue * red / 100);
delay(time);
}
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(red_pin, fadeValue * red / 100); //Red
analogWrite(green_pin, fadeValue * green / 100); //Green
analogWrite(blue_pin, fadeValue * blue / 100); //blue
// wait for 30 milliseconds to see the dimming effect
delay(time);
}
}
void light_spike(byte spike, byte red, byte green, byte blue, int time)
{
//Flashes Color of each spike
switch (spike){
case 0:
digitalWrite(first_spike,LOW);
pinMode(first_spike,OUTPUT);
//Serial.println("First Spike");
pulsecolor(red, green, blue, time);
pinMode(first_spike,INPUT);
break;
case 1:
digitalWrite(second_spike,LOW);
pinMode(second_spike,OUTPUT);
//Serial.println("Second Spike");
pulsecolor(red, green, blue, time);
pinMode(second_spike,INPUT);
break;
case 2:
digitalWrite(third_spike,LOW);
pinMode(third_spike,OUTPUT);
//Serial.println("Third Spike");
pulsecolor(red, green, blue, time);
pinMode(third_spike,INPUT);
break;
case 3:
digitalWrite(forth_spike,LOW);
pinMode(forth_spike,OUTPUT);
//Serial.println("Forth Spike");
pulsecolor(red, green, blue, time);
pinMode(forth_spike,INPUT);
break;
case 4:
digitalWrite(fifth_spike,LOW);
pinMode(fifth_spike,OUTPUT);
//Serial.println("Fifth Spike");
pulsecolor(red, green, blue, time);
pinMode(fifth_spike,INPUT);
break;
case 5:
digitalWrite(left_blade,LOW);
pinMode(left_blade,OUTPUT);
//Serial.println("Left Blade");
pulsecolor(red, green, blue, time);
pinMode(left_blade,INPUT);
break;
case 6:
digitalWrite(right_blade,LOW);
pinMode(right_blade,OUTPUT);
//Serial.println("Right Blade");
pulsecolor(red, green, blue, time);
pinMode(right_blade,INPUT);
break;
}
}
void sendtohead(char command)
{
char msg[5] ={'\0','\0','\0','\0','\0'}; //Build our array with null charactors
msg[0]=command;
vw_send((uint8_t *)msg, 5);
vw_wait_tx();
}
void sendtohead(char command, byte color)
{
char msg[5] ={'\0','\0','\0','\0','\0'}; //Build our array with null,
msg[0]=command;
msg[1]=(char)color; //converted to charactor since color is a byte 1-101
vw_send((uint8_t *)msg, 5);
vw_wait_tx();
}
Multiplexing is a cheap way to make LEDs to allot of stuff with an Arduino!
My "Sketch" below:
/*
Dennis Liang
© Drakes Computers
LED driver controler, 10 wires.
RGB
1,2,3,4,5,6,7
*/
#include <EEPROM.h>
#include <VirtualWire.h>
byte left_blade =10;
byte right_blade =12;
byte first_spike =A2;
byte second_spike = A0;
byte third_spike = A3;
byte forth_spike = A1;
byte fifth_spike = 11;
byte red_pin = 6;
byte green_pin = 5;
byte blue_pin = 3;
boolean disable_power= false;
byte mode = 0;
byte color_red = 100;
byte color_green = 100;
byte color_blue = 100;
#define mode_address 1
#define pwr_address 0
#define red_address 2
#define green_address 3
#define blue_address 4
const byte tx_1_pin = 7;
const byte tx_2_pin = 8;
const byte tx_3_pin = 9;
void setup() {
// nothing happens in setup
//pinMode(10,OUTPUT);
//digitalWrite(10,HIGH);
Serial.begin(115200);
Serial.print(F("$$$"));
delay(100);
Serial.println(F("SN,DrakeTail"));
delay(100);
Serial.println(F("SM,0"));
delay(100);
Serial.println(F("---"));
//Configure Transmitter
pinMode(tx_1_pin,OUTPUT);
pinMode(tx_2_pin,OUTPUT);
pinMode(tx_3_pin,OUTPUT); //VCC pin
digitalWrite(tx_1_pin, LOW);
digitalWrite(tx_3_pin, HIGH);
vw_set_tx_pin(tx_2_pin);
vw_setup(1000);
//Done configuring transmitter
pinMode(red_pin,OUTPUT);
pinMode(green_pin,OUTPUT);
pinMode(blue_pin,OUTPUT);
pinMode(left_blade,INPUT); //left blade
pinMode(fifth_spike,INPUT); //5th spike
pinMode(right_blade,INPUT); //Right blade
pinMode(third_spike,INPUT); //3rd spike
pinMode(second_spike,INPUT); //2nd spike
pinMode(forth_spike,INPUT); //4th spike
pinMode(first_spike,INPUT); //1st spike
randomSeed(analogRead(7)); //initilize the randomizer
mode = EEPROM.read(mode_address); //restore mode
if (EEPROM.read(pwr_address) == 1) //restore power
disable_power = true;
//restore color setting
if (EEPROM.read(red_address) > 100)
color_red = 100;
else
color_red = EEPROM.read(red_address);
if (EEPROM.read(green_address) > 100)
color_green = 100;
else
color_green = EEPROM.read(green_address);
if (EEPROM.read(blue_address) > 100)
color_blue = 100;
else
color_blue = EEPROM.read(red_address);
delay(5000);
while(Serial.available() > 0)
Serial.read();
//Serial.setTimeout(3000);
Serial.print(F("Tail Light controller\r\n©2013 Drakes Computers,\r\nCompiled on\r\n"));
Serial.println(F(__DATE__));
Serial.println(F(__TIME__));
Serial.println(F("Ready."));
}
void loop() {
menu(); ///drive on screen menu
if (!disable_power)
switch (mode)
{
case 0:
light_spike((byte)random(0, 7), (byte)random(0, 100), (byte)random(0, 100), (byte)random(0, 100), 1);
break;
case 1:
down_strobe();
break;
case 2:
up_strobe();
break;
case 3:
ping_pong();
break;
case 4:
//Mode used to switch LEDS on and off?
break;
}
//menu area
}
void down_strobe()
{
static int led_position;
//static unsigned long previousMillis;
//if(millis() - previousMillis > 100) {
// save the last time you blinked the LED
// previousMillis = millis();
light_spike(led_position, color_red, color_green, color_blue, 1); //Change LED position
led_position--;
//}
if (led_position < 0)
led_position = 6;
}
void up_strobe()
{
static int led_position;
//static unsigned long previousMillis;
//if(millis() - previousMillis > 100) {
// save the last time you blinked the LED
// previousMillis = millis();
light_spike(led_position, color_red, color_green, color_blue, 1); //Change LED position
led_position++;
//}
if (led_position > 7)
led_position = 0;
}
void ping_pong()
{
static int led_position;
static boolean led_direction; //goes in reverse
//static unsigned long previousMillis;
//if(millis() - previousMillis > 100) {
// save the last time you blinked the LED
// previousMillis = millis();
light_spike(led_position, color_red, color_green, color_blue, 1); //Change LED position
if (led_direction)
led_position--;
else
led_position++;
//}
if (led_position > 7)
led_direction = true;
if (led_position < 0)
led_direction = false;
}
void menu()
{
int parseint_color = 0;
if (Serial.available() > 0) {
byte serialbyte = Serial.read();
switch (serialbyte) {
case '0': //Changes lighting modes
mode = 0;
Serial.println(F("Mode:0 Random lights and colors"));
EEPROM.write(mode_address,mode);
sendtohead('0');
break;
case '1':
mode = 1;
Serial.println(F("Mode:1 Strobe up"));
EEPROM.write(mode_address,mode);
sendtohead('1');
break;
case '2':
mode = 2;
Serial.println(F("Mode:2 Strobe down"));
EEPROM.write(mode_address,mode);
sendtohead('2');
break;
case '3':
mode = 3; //***********************
Serial.println(F("Mode:3 Ping pong"));
EEPROM.write(mode_address,mode);
sendtohead('3');
break;
/*case '4':
mode = 4; //***********************
Serial.println(F("Mode:4 Manual"));
EEPROM.write(mode_address,mode);
break;
*/
case 'Q':
case 'q':
color_red++;
if (color_red > 100)
color_red = 100;
Serial.print(F("Color_red:")); Serial.println(color_red,DEC);
sendtohead('r',color_red + 1);
break;
case 'W':
case 'w':
color_green++;
if (color_green > 100)
color_green = 100;
Serial.print(F("Color_green:")); Serial.println(color_green,DEC);
sendtohead('g',color_green + 1);
break;
case 'E':
case 'e':
color_blue++;
if (color_blue > 100)
color_blue = 100;
Serial.print(F("Color_blue:")); Serial.println(color_blue,DEC);
sendtohead('b',color_blue + 1);
break;
case 'A':
case 'a':
color_red--;
if (color_red > 100)
color_red = 0; //using wrap around
Serial.print(F("Color_red:")); Serial.println(color_red,DEC);
sendtohead('r',color_red + 1);
break;
case 'S':
case 's':
color_green--;
if (color_green > 100)
color_green = 0; //using wrap around
Serial.print(F("Color_green:")); Serial.println(color_green,DEC);
sendtohead('g',color_green + 1);
break;
case 'D':
case 'd':
color_blue--;
if (color_blue > 100)
color_blue = 0; //using wrap around
Serial.print(F("Color_blue:")); Serial.println(color_blue,DEC);
sendtohead('b',color_blue + 1);
break;
case 'R':
case 'r':
Serial.print(F("RED:\nEnter number(1-101):"));
parseint_color = Serial.parseInt();
if (parseint_color > 0)
color_red = parseint_color-1;
Serial.println(parseint_color,DEC);
sendtohead('r',parseint_color);
break;
case 'G':
case 'g':
Serial.print(F("GREEN:\nEnter number(1-101):"));
parseint_color = Serial.parseInt();
if (parseint_color > 0)
color_green = parseint_color-1;
Serial.println(parseint_color,DEC);
sendtohead('g',parseint_color);
break;
case 'B':
case 'b':
Serial.print(F("BLUE:\nEnter number(1-101):"));
parseint_color = Serial.parseInt();
if (parseint_color > 0)
color_blue = parseint_color-1;
Serial.println(parseint_color,DEC);
sendtohead('b',parseint_color);
break;
case 'p':
case 'P':
Serial.println(F("LED's on!"));
disable_power = false;
EEPROM.write(pwr_address,(byte)disable_power);
sendtohead('p');
break;
case 'O':
case 'o':
Serial.println(F("LED's off!"));
disable_power = true;
EEPROM.write(pwr_address,(byte)disable_power);
sendtohead('o');
break;
case 'f':
case 'F':
Serial.println(F("FAN's on!"));
sendtohead('f');
break;
case 'v':
case 'V':
Serial.println(F("FAN's off!"));
sendtohead('v');
break;
case 'C':
case 'c':
EEPROM.write(red_address,color_red);
EEPROM.write(green_address,color_green);
EEPROM.write(blue_address,color_blue);
Serial.println(F("Settings Saved!"));
break;
case 'L':
case 'l':
Serial.print("SETTINGS:");
Serial.print(mode, DEC);
Serial.print(",");
Serial.print(color_red+1, DEC);
Serial.print(",");
Serial.print(color_green+1, DEC);
Serial.print(",");
Serial.print(color_blue+1, DEC);
Serial.println(".");
break;
//main menu
case '?':
case 'h':
case '\r':
Serial.println(F("*******************"));
Serial.println(F("Available Commands:"));
Serial.println(F("p-Power On"));
Serial.println(F("o-Power Off"));
Serial.println(F("0-Random Flicker"));
Serial.println(F("1-Stobe Up"));
Serial.println(F("2-Stobe Down"));
Serial.println(F("3-Ping Pong"));
//Serial.println(F("4-Manual"));
Serial.println(F("f-FAN ON"));
Serial.println(F("v-FAN OFF"));
Serial.println(F("q-RED++"));
Serial.println(F("w-GREEN++"));
Serial.println(F("e-BLUE++"));
Serial.println(F("a-RED--"));
Serial.println(F("s-GREEN--"));
Serial.println(F("d-BLUE--"));
Serial.println(F("r-RED, set"));
Serial.println(F("g-GREEN, set"));
Serial.println(F("b-BLUE, set"));
Serial.println(F("c-Save color changes."));
Serial.println(F("l-Get settings"));
Serial.print(F("Power:"));
if (disable_power)
Serial.println(F("OFF!"));
else
Serial.println(F("ON!"));
Serial.print(F("Mode:"));
Serial.println(mode,DEC);
Serial.print(F("COLOR:"));
Serial.print(color_red+1, DEC);
Serial.print(",");
Serial.print(color_green+1, DEC);
Serial.print(",");
Serial.print(color_blue+1, DEC);
Serial.println(".");
// Serial.println(F("S-Scan for signal"));
}
//
} //serial port
}
//void fade()
//{
//
// // fade in from min to max in increments of 5 points:
// for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// // sets the value (range from 0 to 255):
// analogWrite(6, fadeValue); //Red
// analogWrite(3, fadeValue);
// analogWrite(5, fadeValue);
// // wait for 30 milliseconds to see the dimming effect
// delay(1);
// }
//
// // fade out from max to min in increments of 5 points:
// for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// // sets the value (range from 0 to 255):
// analogWrite(6, fadeValue);
// analogWrite(3, fadeValue);
// analogWrite(5, fadeValue);
// // wait for 30 milliseconds to see the dimming effect
// delay(1);
// }
//}
void pulsecolor(byte red, byte green, byte blue, int time)
{
/*
Pulse to that color. Pulse time depends on time x color steps
*/
// fade in from min to max in increments of 5 points:
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
// sets the value (range from 0 to 255):
analogWrite(red_pin, fadeValue * red / 100); //Red
analogWrite(green_pin, fadeValue * green / 100); //Green
analogWrite(blue_pin, fadeValue * blue / 100); //Blue
// wait for 30 milliseconds to see the dimming effect
// Serial.print("Fading value:");
// Serial.println(fadeValue * red / 100);
delay(time);
}
// fade out from max to min in increments of 5 points:
for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(red_pin, fadeValue * red / 100); //Red
analogWrite(green_pin, fadeValue * green / 100); //Green
analogWrite(blue_pin, fadeValue * blue / 100); //blue
// wait for 30 milliseconds to see the dimming effect
delay(time);
}
}
void light_spike(byte spike, byte red, byte green, byte blue, int time)
{
//Flashes Color of each spike
switch (spike){
case 0:
digitalWrite(first_spike,LOW);
pinMode(first_spike,OUTPUT);
//Serial.println("First Spike");
pulsecolor(red, green, blue, time);
pinMode(first_spike,INPUT);
break;
case 1:
digitalWrite(second_spike,LOW);
pinMode(second_spike,OUTPUT);
//Serial.println("Second Spike");
pulsecolor(red, green, blue, time);
pinMode(second_spike,INPUT);
break;
case 2:
digitalWrite(third_spike,LOW);
pinMode(third_spike,OUTPUT);
//Serial.println("Third Spike");
pulsecolor(red, green, blue, time);
pinMode(third_spike,INPUT);
break;
case 3:
digitalWrite(forth_spike,LOW);
pinMode(forth_spike,OUTPUT);
//Serial.println("Forth Spike");
pulsecolor(red, green, blue, time);
pinMode(forth_spike,INPUT);
break;
case 4:
digitalWrite(fifth_spike,LOW);
pinMode(fifth_spike,OUTPUT);
//Serial.println("Fifth Spike");
pulsecolor(red, green, blue, time);
pinMode(fifth_spike,INPUT);
break;
case 5:
digitalWrite(left_blade,LOW);
pinMode(left_blade,OUTPUT);
//Serial.println("Left Blade");
pulsecolor(red, green, blue, time);
pinMode(left_blade,INPUT);
break;
case 6:
digitalWrite(right_blade,LOW);
pinMode(right_blade,OUTPUT);
//Serial.println("Right Blade");
pulsecolor(red, green, blue, time);
pinMode(right_blade,INPUT);
break;
}
}
void sendtohead(char command)
{
char msg[5] ={'\0','\0','\0','\0','\0'}; //Build our array with null charactors
msg[0]=command;
vw_send((uint8_t *)msg, 5);
vw_wait_tx();
}
void sendtohead(char command, byte color)
{
char msg[5] ={'\0','\0','\0','\0','\0'}; //Build our array with null,
msg[0]=command;
msg[1]=(char)color; //converted to charactor since color is a byte 1-101
vw_send((uint8_t *)msg, 5);
vw_wait_tx();
}
Category All / All
Species Unspecified / Any
Size 876 x 574px
File Size 57.2 kB
I tried FFT library last weekend, using a multiplexing LED Algorithm unfortunately i got lots of flickering and bad brightness (well i am sharing the PWM lines between all the LEDS in the set).
SO next time I should have something more definite...hehe dragondruino!
SO next time I should have something more definite...hehe dragondruino!
FA+

Comments