#include /* D7 - Ser (data) D5 - clock D1 - _OE D2 - latch D3 - _clear */ //Pins connected to Shift registers on own controller board #define PIN_DATA 13 #define PIN_CLK 14 #define PIN_OE 27 //active low #define PIN_LATCH 26 //Pins connected to stuff on annax driver board #define PIN_DATA_DRVBRD 33 #define PIN_CLK_DRVBRD 32 //#define PIN_CLEAR 25 //active low #define PIN_DRIVE 33 //enables 12v to panels #define NUMPANELS 1 //void sr_clear(); void shiftOutSlow(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); unsigned long loopmillis=0; unsigned long last_update=0; #define UPDATE_INTERVAL 5000 void setup() { pinMode(PIN_DATA, OUTPUT); pinMode(PIN_CLK, OUTPUT); pinMode(PIN_OE, OUTPUT); pinMode(PIN_LATCH, OUTPUT); //pinMode(PIN_CLEAR, OUTPUT); pinMode(PIN_DRIVE, OUTPUT); pinMode(PIN_DATA_DRVBRD, OUTPUT); pinMode(PIN_CLK_DRVBRD, OUTPUT); digitalWrite(PIN_OE, HIGH); //Active Low digitalWrite(PIN_LATCH, LOW); //sr_clear(); digitalWrite(PIN_DRIVE, LOW); Serial.begin(115200); } int countz=0; uint8_t rowA=0; //first shift register of own controller uint8_t rowB=0; //second shift register of own controller uint8_t colA=0; uint8_t colB=0; uint8_t colC=0; uint8_t colD=0; uint8_t colE=0; uint8_t colF=0; uint8_t colG=0; void loop() { loopmillis = millis(); digitalWrite(PIN_OE, LOW); //Active Low if (loopmillis > last_update + UPDATE_INTERVAL) { Serial.print("count="); Serial.print(countz); /* Serial.println("High"); digitalWrite(PIN_DATA, HIGH); delay(1000); Serial.println("Low"); digitalWrite(PIN_DATA, LOW); delay(1000); */ /* rowA=pow(2, (countz/2)%8); if (countz%2==0) { colA=0; }else{ colA=64; //64=IL0 } */ if (countz%2==0) { colC=2+8+32+128; colB=0; }else{ //colA=64; //64=IL0 colC=0; //IH colB=32+128; } //setting colX to 128, 32, 8,2 (or a combination of), then appling 12V to driver and GND to Clear, clears these colums // this applies +12v to selected columns //setting colX to 64,16,4,1 (or a combination of), then setting row shift registers to some setting sets the selected dots // this applies GND to selected columns //reset pin on annax board input should be used (not pulled to gnd for a short time) after dots have been flipped (to disable potentially activated transistors) Serial.print(", rowA="); Serial.print(rowA); Serial.print(", colA="); Serial.print(colA); Serial.println(); //reset pin on ribbon cable high (12Vpullup/open), then low (via Transistor) //Select Columns via Shift registers shiftOutSlow(PIN_DATA_DRVBRD, PIN_CLK_DRVBRD, LSBFIRST, colG); shiftOutSlow(PIN_DATA_DRVBRD, PIN_CLK_DRVBRD, LSBFIRST, colF); shiftOutSlow(PIN_DATA_DRVBRD, PIN_CLK_DRVBRD, LSBFIRST, colE); shiftOutSlow(PIN_DATA_DRVBRD, PIN_CLK_DRVBRD, LSBFIRST, colD); shiftOutSlow(PIN_DATA_DRVBRD, PIN_CLK_DRVBRD, LSBFIRST, colC); shiftOutSlow(PIN_DATA_DRVBRD, PIN_CLK_DRVBRD, LSBFIRST, colB); shiftOutSlow(PIN_DATA_DRVBRD, PIN_CLK_DRVBRD, LSBFIRST, colA); //colA=128(bit 8) sets first output of shift registers high (lsbfirst) //select Rows via shift registers on own controller board shiftOutSlow(PIN_DATA, PIN_CLK, LSBFIRST, rowB); shiftOutSlow(PIN_DATA, PIN_CLK, LSBFIRST, rowA); //LSBFIRST= LSB is QH, bit 8 is QA. digitalWrite(PIN_LATCH, HIGH); delayMicroseconds(100); digitalWrite(PIN_LATCH, LOW); last_update=loopmillis; countz++; } } /* void sr_clear() { digitalWrite(PIN_CLEAR, LOW); delayMicroseconds(1000); digitalWrite(PIN_CLEAR, HIGH); delayMicroseconds(1000); }*/ void shiftOutSlow(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val) { uint8_t i; for (i = 0; i < 8; i++) { if (bitOrder == LSBFIRST) digitalWrite(dataPin, !!(val & (1 << i))); else digitalWrite(dataPin, !!(val & (1 << (7 - i)))); delayMicroseconds(100); digitalWrite(clockPin, HIGH); delayMicroseconds(100); digitalWrite(clockPin, LOW); delayMicroseconds(100); } }