Question
Suppose you are using a robot that has light sensors on its right and left sides, as shown. The light sensors are connected to analog
Suppose you are using a robot that has light sensors on its right and left sides, as shown.
The light sensors are connected to analog input channels 1 and 9 of the TM4C ADC (channel 1 left sensor; channel 9 right sensor). Thus your program should sample both channels.
a. Initialize the ADC to use the channels as indicated. No interrupts are to be used. (7 pts)
i. Briefly describe the initialization tasks at a high level (at a higher level than C code or comments). What features need to be initialized and for what purpose? Do not provide specific register macros or bitwise operations.
ii. Next, write the code.
void init_ADC()
{
YOUR CODE HERE (suggestion: you may want to structure your code similar to the UART initialization given in question 3)
}
b. Complete the following function to read in the light sensor values and return them via the parameters. Use polling (i.e. no interrupt service routines). (5 pts)
void get_sensor_reading(int *left_sensor, int *right_sensor)
{
YOUR CODE HERE
}
The following is the UART initialization code from question 3:
Turn away from light Front Robot Back Turn away from light Front Robot Back
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started