shift register all outputs high
i using 74hc595n 7 segment display. code me identify bits controlling specific segments, reason when last segment displayed, light up. byte sent register has value of 128 , yet acts 255. more bizarre same thing values on 128. also, expected, 127 shows last segment.
here's code:
i have no idea problem is. advice?
here's code:
code: [select]
const int datapin1 = 4; //pin 14 on chip
const int latchpin = 5; //pin 12 on chip
const int clockpin = 6; //pin 11 on chip
int incomingbyte;
int i=0;
byte onesdigit = 0;
void setup()
{
serial.begin(9600);
pinmode(datapin1,output);
pinmode(datapin2,output);
pinmode(latchpin,output);
pinmode(clockpin,output);
onesdigit=0;
serial.println("would iteration?");
}
void loop()
{
updateregister1();
if(serial.available())
{
incomingbyte = serial.read();
}
if (incomingbyte==121)
{
onesdigit=0;
bitset(tensdigit,i);
updateregister1();
serial.print("i value: ");
serial.println(i);
i++;
serial.print("onesdigit value: ");
serial.println(tensdigit);
serial.println("would iteration?");
}
incomingbyte=1;
if(i>8)
{
i=0;
}
}
void updateregister1()
{
digitalwrite(latchpin, low);
shiftout(datapin1, clockpin, msbfirst, onesdigit);
digitalwrite(latchpin, high);
}
i have no idea problem is. advice?
supply decoupling on shift register. have got any?
http://www.thebox.myzen.co.uk/tutorial/de-coupling.html
http://www.thebox.myzen.co.uk/tutorial/de-coupling.html
Arduino Forum > Using Arduino > LEDs and Multiplexing > shift register all outputs high
arduino
Comments
Post a Comment