Created
August 18, 2017 07:57
-
-
Save urmil0071/35c037b8951ca7b6f5a1569254d3a9f8 to your computer and use it in GitHub Desktop.
BCD-to-BINary Conversion of Unsigned Numbers using Counting Method (Slow Process)
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
#include <Arduino.h> | |
void setup() | |
{ | |
int x=0x0125; | |
byte shift[]={0,4,8,12}; | |
byte positionMult[]={1,10,100,1000}; | |
int xx; | |
int opbin; | |
for (int i=0;i<=3;i++) | |
{ | |
xx=x>>shift[i]; | |
xx=xx&0x000F; | |
while (xx !=0) | |
{ | |
opbin=opbin + positionMult[i]; | |
xx--; | |
} | |
} | |
Serial.begin(9600); | |
Serial.println(x,HEX); | |
Serial.println(opbin,BIN); | |
} | |
void loop() | |
{ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment