Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Teeces V3 Sketch for Arduino Pro Mini with 1 chain (RLD->FLD->FLD->PSI->PSI)
- // with John V's PSI slide method (using the standard PSI LED pattern)
- //
- #include <LedControl.h>
- #undef round
- class PSI
- {
- int stage; //0 thru 4
- int inc;
- int stageDelay[5];
- int cols[5];
- unsigned long timeLast;
- int device;
- public:
- PSI(int _delay1, int _delay2, int _device)
- {
- device=_device;
- stage=0;
- timeLast=0;
- inc=1;
- cols[0] = B11000000;
- cols[1] = B11100000;
- cols[2] = B01100000;
- cols[3] = B01110000;
- cols[4] = B00110000;
- stageDelay[0] = _delay1 - 300;
- stageDelay[1] = 100;
- stageDelay[2] = 100;
- stageDelay[3] = 100;
- stageDelay[4] = _delay2 - 300;
- }
- void Animate(unsigned long elapsed, LedControl control)
- {
- if ((elapsed - timeLast) < stageDelay[stage]) return;
- timeLast = elapsed;
- stage+=inc;
- if (stage>4 || stage<0 )
- {
- inc *= -1;
- stage+=inc*2;
- }
- for (int row=0; row<4; row++)
- control.setRow(device,row,cols[stage]);
- }
- };
- PSI psiFront=PSI(2000, 1000, 5); //2000 ms on red, 1000 ms on blue. device is 5
- PSI psiRear =PSI(1000, 2000, 6); //1000 ms on yellow, 2000 ms on green. device is 6
- 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(0, 7); //RLD
- lc.setIntensity(1, 7); //RLD
- lc.setIntensity(2, 7); //RLD
- lc.setIntensity(3, 5); //FLD
- lc.setIntensity(4, 5); //FLD
- lc.setIntensity(5, 15); //PSI
- lc.setIntensity(6, 15); //PSI
- // pinMode(13, OUTPUT);
- // digitalWrite(13, HIGH);
- //HP lights on constant
- lc.setRow(5,4,255);
- lc.setRow(6,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) < 200) return;
- timeLast = elapsed;
- for (int dev=0; dev<5; dev++)
- for (int row=0; row<6; row++)
- lc.setRow(dev,row,random(0,256));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement