Hello. I need help converting 1 byte into 2 nibbles and print them. I tried this but it doesn't work.
const int analogInPin0 = A0;
int readByte = 0;
int mappedByte = 0;
int bottom_nibble = 0;
int top_nibble = 0;
void setup() {
// initialize serial communications at 115200 bps:
Serial.begin(115200);
}
void loop() {
readByte = analogRead(analogInPin0);
mappedByte = map(readByte, 0, 1023, 0, 255);
bottom_nibble = readByte & 0xf;
top_nibble = ( readByte > 4 ) & 0xf;
Serial.print(bottom_nibble);
Serial.print(top_nibble);
delay(10);
}
Thanks!