Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

x-3+1, x23 Let f(x) = -*+3, * Answered: 1 week ago

Answered: 1 week ago

Question

1. What would you do if you were Jennifer, and why?

Answered: 1 week ago