int dataPin = 10; //Define which pins will be used for the Shift Register control int latchPin = 9; int clockPin = 8; long i = 1; int pauseTime = 100; // byte #2 value bool left = true; bool buttonPushed=false; volatile int state=LOW; unsigned long time; unsigned long lasttime; void setup() { attachInterrupt(0,pushit,LOW); pinMode(dataPin, OUTPUT); //Configure each IO Pin pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); pinMode(12,OUTPUT); digitalWrite(12,state); lasttime==millis(); } void loop() { displayLed(i); if(buttonPushed){ for(int loopVar=0;loopVar<10;loopVar++){ displayLed(0); delay(150); displayLed(i); delay(150); } buttonPushed=false; } if (left ){ i = i << 1; } else { i = i >> 1; } if (i == 32768 || i == 1){ left = !left; } delay(pauseTime); if (pauseTime <= 0){ pauseTime = 100; } } void pushit(){ time=millis(); if (time-lasttime>50){ digitalWrite(12,!state); state=!state; lasttime = time; pauseTime = pauseTime - 2; buttonPushed=true; } } void displayLed(unsigned long iVal){ digitalWrite(latchPin, LOW); //Pull latch LOW to start sending data if (iVal > 255){ shiftOut(dataPin,clockPin,MSBFIRST,0); shiftOut(dataPin,clockPin,MSBFIRST,iVal/256); } else { shiftOut(dataPin,clockPin,MSBFIRST,iVal); shiftOut(dataPin,clockPin,MSBFIRST,0); } digitalWrite(latchPin, HIGH); //Pull latch HIGH to stop sending data }
I guess I have to do some tinkering.
HEy, regarding the LCD being 14 pins, most have 16, since 2 extra are used for backlight powering.
ReplyDeleteGood luck.
I was thinking that, maybe, the red wire was for the backlight. There is also four connections on the side that I have no idea what they are. Was going to try to connect the red wire to 5 volts and see what happens. Thanks for taking the time to read/comment.
Delete