//Led matrix defines int dataPin = 7; int latchPin = 6; int clockPin = 5; int ledCol[8] = { 8,9,10,11,14,15,16,17 }; //did I mention this was a dirty fix? //interrupt #define ISR_FREQ 370 //740Hz // Sets the speed of the ISR - LOWER IS FASTER byte testFrame[8] = { B10000000, B01000000, B00100000, B00010000, B00001000, B00000100, B00000010, B00010001, }; byte ConvertedFrame[8] = { B10000000, B01000000, B00100000, B00010000, B00001000, B00000100, B00000010, B00010001, }; //----------------------- //Led stuff void ledsetup() { for (int i = 0; i < 8; i++) pinMode(ledCol[i], OUTPUT); pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(dataPin, OUTPUT); } void setLedFrame(byte inFrame[8]) { for (int I = 0; I < 8; I++) testFrame[I] = inFrame[I]; } void clearLed() { for (int I = 0; I < 8; I++) testFrame[I]=0; } void lightAllLed() { for (int I = 0; I < 8; I++) testFrame[I]=255; } void toggleLed(int x, int y) { testFrame[x] ^= (1 << (7-y)); } void setLed(int x, int y) { testFrame[x] |= (1 << (7-y)); } void clearLed(int x, int y) { testFrame[x] &= ~(1 << (7-y)); } int get(int x, int car_num) { return testFrame[x] & 1<=3) { int val; val = Serial.read(); // read the serial port if (val=='1') //set Led { setLed(Serial.read()-48,Serial.read()-48); } else if (val=='0') //clear Led { clearLed(Serial.read()-48,Serial.read()-48); } else if (val=='2') //toggleLed { toggleLed(Serial.read()-48,Serial.read()-48); } else if (val=='3') //toggleLed { testFrame[Serial.read()]=Serial.read(); } else if(val=='6') { int a=Serial.read(); int b=Serial.read(); if (a=='0') clearLed(); if (a=='1') lightAllLed(); } } } //------------------- void setup() { ledsetup(); clearLed(); Serial.begin(9600); //start serial randomSeed(analogRead(0)); } void loop() { int row =2; protocolRun(); ledRun(); }