So I now get the correct combined value. in order to pass it to the "shiftOut" it needs to have the "0b in front of it, how do I combine them and pass it?
I keep getting 'data' was not declared in this scope
if I try to assign the "combined" value to "data" which is sent to the shift register.
const int dataPin = 5;
const int clockPin = 4;
void setup() {
Serial.begin(9600);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
uint32_t data = 0;
uint32_t combined = 0;
uint8_t byte3 = 0b00000011; //1
uint8_t byte2 = 0b01101101; //2
uint8_t byte1 = 0b01100111; //3
uint8_t byte0 = 0b01010011; //4
combined = ((uint32_t)byte3 << 24) |((uint32_t)byte2 << 16) | ((uint32_t)byte1 << 8) | (uint32_t)byte0;
Serial.print("COMBINED: ");
Serial.println(combined, BIN);
}
void loop() {
//uint32_t data = 0b11011011010110011101010011; //1-2-3-4 this works
//uint32_t data = 0x036D6753; //1-2-3-4 this works
shiftOut(dataPin, clockPin, LSBFIRST, data );
shiftOut(dataPin, clockPin, LSBFIRST, data >> 8 );
shiftOut(dataPin, clockPin, LSBFIRST, data >> 16 );
shiftOut(dataPin, clockPin, LSBFIRST, data >> 24 );
delay (500);
}//end loop
Maybe I'm missing something here? Why do you need to combine them at all? Just send the 4 bytes out one after the other as they are.
As for bytes and bits it doesn't matter. A byte is a byte is a byte. Displaying it as bits or bytes or a decimal number or nano parsecs doesn't make any difference, it's still a byte, which is still 8 bits.
I think you are doing a lot of unnecessary messing about.
Think about what the hardware is actually doing when it does what you ask of it.
I have seen similar attempts to combine data for Serial.print, which is also unnecessary, you just print things individually in the order they need to be sent.
I'm not familiar with the shiftOut function, but from your description of what you are doing I would think SPI would be a better choice. SPI is basically a shift register with some clock circuitry, it is intended for this kind of thing.