Hi,
I'm trying to work with a shift register so as part of the learning curve I wanted to make sure I can activate all the output pins on the shift register.
I take a variable and inside a loop shift it the number 1 buy the number of steps of the loop.
This works fine from 0 to 6 but when I get to 7 I get a strange output
i is: 7
Display1 is: 11111111111111111111111110000000
The code I'm using is:
// hardware constants
int LEDClockPin = 12; // Arduino Pin #12 - 4094 Pin 3 clock
int LEDDataPin = 11; // Arduino Pin #11 - 4094 pin 2 Data
int LEDStrobePin = 10; // Arduino Pin # 10 - 4094 pin 1 Strobe
char Display1=0;
void setup()
{
// initialise the hardware
// initialize the appropriate pins as outputs:
pinMode(LEDClockPin, OUTPUT);
pinMode(LEDDataPin, OUTPUT);
pinMode(LEDStrobePin, OUTPUT);
Serial.begin(19200); // setup the serial port to 9600 baud
}
void loop()
{
Display1 = 0;
for (int i=0;i< 8; i++)
{
Display1 = (1<<i);
digitalWrite(LEDStrobePin,LOW);
shiftOut(LEDDataPin, LEDClockPin, MSBFIRST,Display1);
Serial.print("i is: ");
Serial.println(i,DEC);
Serial.print("Display 1 is: ");
Serial.println(Display1,BIN);
digitalWrite(LEDStrobePin,HIGH);
delay(1000);
}
}
Would appreciate any advice on what I'm doing wrong.
Thanks