Answered step by step
Verified Expert Solution
Question
1 Approved Answer
void main ( ) f unsigned short current _ duty, old _ duty, current _ duty 1 , old _ duty 1 ; PORTA =
void main f
unsigned short currentduty, oldduty, currentduty oldduty;
PORTA ;
TRISA ; configure PORTA pins as input
PORTB ; set PORTB to
TRISB ; designate PORTB pins as output
PORTC ; set PORTC to
TRISC ; designate PORTC pins as output
PWMInit; Initialize PWM module at
PWMInit; Initialize PWM module at KHz
currentduty ; initial value for currentduty
currentduty; initial value for currentduty
PWMStart; start PWM
PWMStart; start PWM
PWMSetDutycurrentduty; Set current duty for PWM
PWMSetDutycurrentduty; Set current duty for PWM
while endless loop
if RAObit button on RAO pressed
Delayms;
currentduty; increment currentduty
PWMSetDutycurrentduty;
if RAbit button on RA pressed
Delayms; decrement currentduty
PWMSetDutycurrentduty;
if RAbit f button on RA pressed
Delayms;
currentduty; increment currentduty
PWMSetDutycurrentduty;
if RAbit f button on RA pressed
Delayms;
currentduty; decrement currentduty
PWMSetDutycurrentduty;
Delayms; slow down change pace a little
H
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