Hi.
I am working on controlling a thermal printhead. Put simply, it's just a long shift register, you clock in data, flip a latch signal, enable heat for a second and you print a line. Rinse and repeat.
I tried making a test program with the ShiftOut function, but i get unpredictable results

My code looks like this:
//**************************************************************//
// Name : Test code for Thermal printhead //
//****************************************************************
int ENPin = 3;
int clockPin = 4;
int dataPin = 5;
int Strobe1 = 2; // digital pin 2 connected to Strobe1
void setup() {
pinMode(ENPin, OUTPUT); // sets the digital pin as output
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(Strobe1, OUTPUT);
digitalWrite(ENPin, HIGH); // Make sure all outputs are high
digitalWrite(clockPin, HIGH);
digitalWrite(dataPin, HIGH);
digitalWrite(Strobe1, HIGH);
shiftOut(dataPin, clockPin, LSBFIRST, B01010101); // Clock out the 8 bits to the shift register
digitalWrite(ENPin, LOW); // Toggle Latch on shift register
delayMicroseconds(2);
digitalWrite(ENPin, HIGH);
}
void loop() {
digitalWrite(Strobe1, LOW); // Strobe the heating elements
delay(10);
digitalWrite(Strobe1, HIGH);
delay(100);
}
And the outputs look like this when viewed with my logic analyser:

I have read the doc for ShiftOut and i cannot see why ENPin and Strobe1 is toggled at the start of the ShiftOut part of the program.
Thanks in advance
// Per.