Question
Modify the C function readDigitValue() in Lab 2 to read in a hexadecimal number of two digits. Call the new function readHexValue(). Make sure your
Modify the C function readDigitValue() in Lab 2 to read in a hexadecimal number of two digits. Call the new function readHexValue(). Make sure your code recognize all hexadecimal digits from 0 to 9, A to F, and a to f (lower case). This function should print out the number in both hexadecimal and decimal to verify your program is correct.
byte read2DigitValue() { byte inch; int val; Serial.println("Enter a 2-digit decimal value:"); while (!Serial.available()) delay(100); inch = Serial.read(); val = (inch - '0') * 10; while (!Serial.available()) delay(100); inch = Serial.read(); val += (inch - '0'); Serial.print("The value entered is "); Serial.println(val,DEC); return (byte) val; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started