Hello,
I'm running a ProMini and I'm seeing an unexpected result. Can someone please confirm if it's my code or the Arduino Mal-processing the result.
What i expect is to see in the register:
00000000 // Clear
then
00000001
00000011
...
00111111
01111111
11111111
But what i get is ...
00000000
then
00000001
00000011
...
00111111
01111111
-1 <--- WHAT THE, That's not 0xFF or B1111111?
What i see happening is when i try to bitWrite bit 15 to a 1 ... I get a overflow and not a 0xFF. Is this me or the Arduino? (I also see variable containing the bit 15 change to bit 16?)
SOLUTION:
int LED_New_ShiftRegister = 255;
SHOULD BE:
unsigned int LED_New_ShiftRegister = 0xFFFF;
THANK YOU for any help!
Mr.Deek
Clode Example Below:
int LED_New_ShiftRegister = 255;
void loop()
{
// Set the shift register to 00000000
for (int X=0; X<16; X++)
{
LEDModRegister(X, 0);
};
LEDShiftOut();
delay(1000);
// Step the shift register +1 to 00000001 .. to 11111111
for (int X=0; X<16; X++)
{
LEDModRegister(X, 1);
LEDShiftOut();
delay(100);
};
delay(1000);
}
// Function
int LEDModRegister(int WhichLED, int LEDSTATE)
{
Serial.print ("SHIFT1: ");
Serial.print (WhichLED);
Serial.print ("\n");
bitWrite(LED_New_ShiftRegister, WhichLED, LEDSTATE);
Serial.print ("SHIFT2: ");
Serial.print (WhichLED);
Serial.print ("\n");
return true;
}