Hello I'm trying to perform some bit manipulations using a 74HC595 IC to light up 8 leds.
I just did the basics, like the circular shift.
This is the code that I'm using for the circular shift:
int latchPin = 11;
int clockPin = 9;
int dataPin = 12;
int dt = 2000;
uint8_t n1 = 128, n2 = 1;
byte myByte = 0b10000001; //in BIN
void setup() {
Serial.begin(9600);
pinMode(latchPin,OUTPUT);
pinMode(dataPin,OUTPUT);
pinMode(clockPin,OUTPUT);
}
//circular shift to the left
void loop() {
digitalWrite(latchPin,LOW);
shiftOut(dataPin,clockPin,LSBFIRST,myByte);
digitalWrite(latchPin,HIGH);
Serial.print("BIN: ");
Serial.print(myByte,BIN);
Serial.print(" --> ");
Serial.print("HEX: ");
Serial.print(myByte,HEX);
Serial.print(" --> ");
Serial.print("DEC: ");
Serial.println(myByte,DEC);
myByte = myByte/128 + myByte*2; //shift by left //using MSBFIRST
//myByte = myByte*2; //shift by right //using MSBFIRTS
delay(dt);
}
But now I would like to obtain an output like this in myByte:
1 0 0 0 0 0 0 1
0 1 0 0 0 0 1 0
0 0 1 0 0 1 0 0
0 0 0 1 1 0 0 0
0 0 0 1 1 0 0 0
0 0 1 0 0 1 0 0
0 1 0 0 0 0 1 0
1 0 0 0 0 0 0 1.....
and so on it repeats
I've read some people use iostream in c++ to perform an output like this, but if i understood well arduino has not enough memory to run iostream or other heavy library.
How can I perform this task? Thank You