Hi everyone,
I'm new in Arduino and I'm trying to understand this piece of a code that I found.
d=0; for (int i=0; i <= 6; i++) {/*if (ar[12+i]==1) Serial.print("1"); if (ar[11+i]==0) Serial.print("0");*/
d=d << 1; d=d+ar[12+i]; } // Serial.print(d); Serial.print(" "); // Device ID
d=0; for (int i=0; i <= 3; i++) {d=d << 1; if (ar[20+i]==1) b=0; else b=1; d=d+b;Serial.print(d+" ");} d=d-5; t=d*100; // tens of degrees
d=0; for (int i=0; i <= 3; i++) {d=d << 1; if (ar[24+i]==1) b=0; else b=1; d=d+b;Serial.print(d+" ");} t=t+10*d; // ones of degrees
d=0; for (int i=0; i <= 3; i++) {d=d << 1; if (ar[28+i]==1) b=0; else b=1; d=d+b;Serial.print(d+" ");} t=t+d; // decimal parts of degrees
t=t/10;
What the code does, is to calculte the temperature received from a sensor. It recieves bits for example, 1000 1010 1101, to get the tens of degrees, then ones and finally decimal part. But i can't understand how it works, because I don't know what does the << statement.
Thank you so much!