Using the PWM module, write a program to operate the motor as follows; when the on-board button is pressed and held, the red on-board LED should flash 10 times with a 0.2 second on-time and a 0.2 second off-time. Once the LED flashes 10 times, the motor should operate in the forward direction with a 100% duty cycle. When the on-board button is released, the motor should stop first, then the on-board LED should flash 5 times with a 0.5 second on-time and a 0.5 second off-time. The motor should then operate in the reverse direction with a 60% duty cycle. Use a value of 34 kHz for Fpwmand use one of the Timer modules or delay functions to create the time delays.
Also, connect a green LED and red LED to the microcontroller. The green LED should illuminate when the motor is rotating in the forward direction and the red LED should illuminate when the motor is rotating in the reverse direction. Do not forget to use a current limiting resistor (470 Ω) for each LED.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here