Last active
January 2, 2021 05:21
-
-
Save sdrshnptl/f6702ad3a1d5b74e9d2124be8e864ee5 to your computer and use it in GitHub Desktop.
Arduino binary to decimal using bit shift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int a,b,c,d; | |
int i; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); | |
for(i = 0; i < 16 ; i++) | |
{ | |
a = i & 0x01; | |
b = i >> 1 & 0x01; | |
c = i >> 2 & 0x01; | |
d = i >> 3 & 0x01; | |
Serial.print(a);Serial.print(" "); | |
Serial.print(b);Serial.print(" "); | |
Serial.print(c);Serial.print(" "); | |
Serial.print(d);Serial.println(" "); | |
} | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment