Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If Pressed RA 3 button, what will happen? void main ( ) f unsigned short current _ duty, old _ duty, current _ duty 1

If Pressed RA3 button, what will happen?
void main() f
unsigned short current_duty, old_duty, current_duty1, old_duty1;
PORTA =255;
TRISA =255;
PORTB =0;
TRISB =0;
PORTC =0;
TRISC =0;
PWM1_Init(5000);
PWM2_Init(5000);
current_duty =16;
current_duty 1=16;
PWM1_Start():
PWM2_start();
PWM1_Set_Duty(current_duty):
PWM2_Set_Duty(current_duty1);
while (1) I
if (RAO_bit)(
Delay_ms(40);
current_duty++;
PWM1_Set_Duty(current_duty):
I
if (RA1_bit){
Delay_ms(40);
current_duty - ; // decrement current_duty
PWM1_Set_Duty(current_duty):
I
if (RA2_bit)1
Delay_ms(40);
current_duty1++; // increment current_duty1
PWM2_Set_Duty(current_duty1);
l
if (RA3_bit)1
Delay_ms(40);
current_duty1-,?? decrement current_duty1
PWM2_Set_Duty(current_duty1);
I
Delay_ms(5):
H
// configure PORTA pins as input
??? set PORTB to 0
// designate PORTB pins as output
// set PORTC to 0
// designate PORTC pins as output
// Initialize PWM1 module at 5KHz
// Initialize PWM2 module at 5KHz
// initial value for current_duty
// initial value for current_duty1
// start PWM1
// start PWM2
// endless loop
// button on RAO pressed
// button on RA1 pressed
set current duty for PWM1
hiset current duty for PWM2
// button on RA2 pressed
f (RA2_bit)1// button on Delay_ms(40); current_duty1++; // incre PWM2_Set_Duty(current_duty1);
// button on RA3 pressed
Delay_ms(5): // slow down change pace a little
// slow down change pace a little
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

clarify and articulate your research methodology;

Answered: 1 week ago

Question

consider how to build on prior learning.

Answered: 1 week ago