b. Copy the text below into your program. /* * Purpose: Read a 0V-5V value from...

50.1K

Verified Solution

Question

Electrical Engineering

b. Copy the text below into your program. /*

* Purpose: Read a 0V-5V value from analog pin A1

* and convert it to a 10-bit (0-1023) number. */

void setup() {

Serial.begin(115200); //set serial comm to 115 kbps }

void loop()

{ int pot_val; //input - potentiometer value

// analogRead() converts 0V-5V to 0-1023 pot_val =analogRead(1);

//read from Analog pin 1 Serial.println(pot_val); //print toserial monitor }

c. Add the function delay() from lab0 to make the readings 1xper second.

d. Write code to display formatted output on the serial monitoras shown below:

Voltage Integer Binary HEX

0.406 83 1010011 53

0.415 85 1010101 55 ...

(ii) Write a formula for converting an integer value (0 to 1023)to an analog voltage, where 0V corresponds to integer 0 and 5Vcorresponds to integer 1023.

Answer & Explanation Solved by verified expert
4.0 Ratings (425 Votes)
b The analogReadpin function reads the value from thespecified analog pin It returns a 10bit integer that maps inputvoltages between 0 and 5 volts to 0 and 1023 More informationabout the function can be found herehttpswwwarduinoccreferenceenlanguagefunctionsanalogioanalogreadThe original program is Purpose Read a 0V5V value from analog pin A1 and convert    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students