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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!