Reference no: EM132168446
Using Eclipse
Your aim is to output two PWM signals on the OC0A and OC0B pins of the microcontroller.
We will then use these to drive the "faster" motor to slow it down to match the "slow" motor in both forward and reverse.
Experiment with setting up and configuring the Timer 0 to generate PWM signals. Use an oscilloscope and a multimeter to view the signal and measure the effective voltage on the OC0A and OC0B pins.
Write a function that does all the setup of Timer 0 instead of doing it in main. Set it up to output the correct PWM signals but disable the outputs until needed later - use the COM0xx bits to do this.
Write a function called "drive". Pass it a parameter that controls whether the bot drives forward, backward, left, right or stops.
To begin with only implement the drive forward functionality.
In this function use timer 0 to drive the "fast" motor. You can simply enable the PWM output you set up in the previous function again using the COM0xx bits.
Integrate this code with your code from either your Lab Assignment 4 or the USART library I provided while working on the ultrasonic sensor to remote control your "bot".
Simulate the motors by using LEDs - e.g. one LED each for right-forward, left-forward, right-reverse, left-reverse.
Use keys of your choice to trigger forward, backward, left, right and stop.
Use #defines to set the PWM pulse width etc and not "magic numbers"!