In this task, we'll use a sketch to allow user input to show Arabic numerals in binary.
// Binary number from input number
int inputNumber;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("enter a number: ");
while(Serial.available()==0){}
inputNumber = Serial.parseInt();
Serial.print("Arabic number: ");
Serial.print(inputNumber);
Serial.print("\tBinary: ");
Serial.println(inputNumber, BIN);
while(Serial.available()>0){
Serial.read();
}
}
Watch the video below to follow along with writing the code.