Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LedControl.h>
- #undef round
- // Teeces V3 Basic Sketch
- // With dumbed-down easily configured options at the start,
- // so you can easily adjust chain order, brightness and speeds.
- // Define devices here. These numbers will change depending on
- // what order you have everything connected in the chain.
- int rld1dev=0; //first LED driver on RLD
- int rld2dev=1; //second LED driver on RLD
- int rld3dev=2; //third LED driver on RLD
- //
- int psi1dev=3; //LED driver on Rear (Green/Yellow) PSI
- int psi2dev=4; //LED driver on Front (Red/Blue) PSI
- //
- int fld1dev=5; //LED driver on FLD 1
- int fld2dev=6; //LED driver on FLD 2
- //
- // Logic Display settings...
- int rldbright=12; // RLD brightness (0 to 15)
- int fldbright=7; // FLD brightness (0 to 15)
- int logicdelay=175; // adjust this number to change the speed of the logic patterns (lower is faster)
- //
- // PSI settings...
- int psibright=15; // PSI brightness (0 to 15)
- int red=2000; // time (in milliseconds) to stay red (default is 2000)
- int blue=1000; // time (in milliseconds) to stay blue (default is 1000)
- int yellow=1000; // time (in milliseconds) to stay yellow (default is 1000)
- int green=2000; // time (in milliseconds) to stay green (default is 2000)
- //
- // We're done with setting numbers.
- // We shouldn't have to change anything below here.
- //
- class PSI
- {
- bool state;
- unsigned long timeLast;
- int delay1, delay2;
- int device;
- public:
- PSI(int _delay1, int _delay2, int _device)
- {
- delay1=_delay1;
- delay2=_delay2;
- device=_device;
- state=false;
- timeLast=0;
- }
- void Animate(unsigned long elapsed, LedControl control)
- {
- if (state && (elapsed - timeLast) < delay1) return;
- if (!state && (elapsed - timeLast) < delay2) return;
- timeLast = elapsed;
- state=!state;
- int cols=B11000000;
- if (state) cols=B00110000;
- for (int row=0; row<4; row++)
- control.setRow(device,row,cols);
- }
- };
- PSI psiFront=PSI(red, blue, psi1dev); //2000 ms on red, 1000 ms on blue.
- PSI psiRear =PSI(yellow, green, psi2dev); //1000 ms on yellow, 2000 ms on green.
- LedControl lc=LedControl(12,11,10,7);
- void setup()
- {
- for(int dev=0;dev<lc.getDeviceCount();dev++)
- {
- lc.shutdown(dev, false); //take the device out of shutdown (power save) mode
- lc.clearDisplay(dev);
- }
- lc.setIntensity(rld1dev, rldbright); //RLD
- lc.setIntensity(rld2dev, rldbright); //RLD
- lc.setIntensity(rld3dev, rldbright); //RLD
- lc.setIntensity(fld1dev, fldbright); //FLD
- lc.setIntensity(fld2dev, fldbright); //FLD
- lc.setIntensity(psi1dev, psibright); //PSI
- lc.setIntensity(psi2dev, psibright); //PSI
- // pinMode(13, OUTPUT);
- // digitalWrite(13, HIGH);
- //HP lights on constant
- lc.setRow(psi1dev,4,255);
- lc.setRow(psi2dev,4,255);
- }
- void loop()
- {
- unsigned long timeNew= millis();
- psiFront.Animate(timeNew, lc);
- psiRear.Animate(timeNew, lc);
- animateLogic(timeNew);
- }
- void animateLogic(unsigned long elapsed)
- {
- static unsigned long timeLast=0;
- if ((elapsed - timeLast) < logicdelay) return;
- timeLast = elapsed;
- for (int row=0; row<6; row++)
- {
- lc.setRow(rld1dev,row,random(0,256));
- lc.setRow(rld2dev,row,random(0,256));
- lc.setRow(rld3dev,row,random(0,256));
- lc.setRow(fld1dev,row,random(0,256));
- lc.setRow(fld2dev,row,random(0,256));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement