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.