(1) Write a program using the provided template and the Arduino IDE that impleme
ID: 3795197 • Letter: #
Question
(1) Write a program using the provided template and the Arduino IDE that implements the binary search described above.
Yourprogramshouldexecuteaforloopthatoutputsaguessvoltage,Vguess,thenreadsinputpinpinNo andfinally generates a new guess voltage according to the binary search algorithm. The for loop should be executed until the algorithm converges to the correct voltage level. Once the for loop has been completed, your program should display the guessed value on the 7-segment LED. The basic outline of your program, therefore, should be structured as outlined below: You will need to make modifications to this program as necessary.
Program Template:
lower = 0;
upper = 8; NOTE: Due to truncation and floating point values, setting upper value to 8
}
will help yield correct values
The above listing only outlines the basic structure of the algorithm. You will need to modify the preceding listing to obtain a working program. Be sure to include a listing of your preliminary program in the lab-book. Also explain how the program works.
(2) Plot the voltage values that your program will converge to as a function of the reference voltages.
Explanation / Answer
#include #include #include using namespace std; int ChangeCase(char s[]){ int i=0; char c; while (s[i]) { c=s[i]; if (islower(c)) {c=toupper(c);putchar (c);} else (isupper(c)){c=tolower(c);putchar (c);} i++;} return 0;} int main(){ char s[]; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.