Through another arduino i am feeding 0x0F but in other arduino(receiver) i am reading all kind of junk values but not 0x0F what could be the mistake on my part
const int pin2 = 2;
const int pin4 = 4;
int clock;
int clock1;
void setup()
{
pinMode(pin2, INPUT);
pinMode(pin4, INPUT);
Serial.begin(2400);
}
void loop()
{
static byte val = 0b00000001;
static byte value = 0b00000000;
clock = digitalRead(pin2);
if ((clock == HIGH) && (clock1 == LOW)) {
val <<= 1;
value |= digitalRead(pin4);
value <<= 1;
if(val | 0x80) { // flag bit has reached the top of the byte so we've done 8 iterations
Serial.print(value, HEX);
Serial.println();
val = 0b00000001;
// value = 0b00000000;
}
}
clock1= clock;
}
Thanks in advance
Niladri