I have to shift per 1 bit.
in Zilog Microcontroller, I do this:
int dataShift = 0x80 //Start from the value leftmost bit
for_loop... from 1 to 8
if(dataShift==0x00) dataShit = 0x80; //reset if data becomes 0
PAOUT = dataShift;
dataShift=dataShift>>1; //shift 1 bit at a time
The codes above is only for shifting one bit at a time.
But here comes my problem:
I have to shift one bit at a time, but when it comes to the right most bit, the display will be still. Ughh, I can't describe it well. But I have a picture below.
loop[0] = 1000 0000 up to 0000 0001
loop[1] = 1000 0001 up to 0000 0011
loop[2] = 1000 0011 up to 0000 0111
It's not tested with LED's and it is not elegant but something like this...
const byte ledPins[] = {2,3,4,5,6,7,8,9}; // List of pins the LED's are connected to
void setup(){
Serial.begin(115200);
Serial.println("Begin");
for (byte x = 0; x < sizeof(ledPins); x++){
pinMode(ledPins[x],OUTPUT);
digitalWrite(ledPins[x],LOW);
}
}
void loop() {
byte x,y;
for (x = 0; x < sizeof(ledPins); x++){
for (y = sizeof(ledPins); y > x; y--){
digitalWrite(ledPins[y-1],HIGH);
delay(100);
digitalWrite(ledPins[y-1],LOW);
Serial.print(ledPins[y-1]);
Serial.print(" ");
}
digitalWrite(ledPins[y],HIGH);
Serial.print(ledPins[y]);
Serial.println();
}
Serial.println("End");
while (1){};
}
The problem with trying to convert the Z80 code is the UNO only has one 8 bit port but it includes pin 0 & 1 so if you want to use serial then this rules out direct port manipulation of D