Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Someone please help! I have fallen very far behind in class and forgotten how to

ID: 2080696 • Letter: S

Question

Someone please help! I have fallen very far behind in class and forgotten how to do simple things. This C++ program needs to work for the ARDUINO I very much appreciate any help!

Write a C++ program for Lab #5 to produce a PWM output according to the following specifications:

• Begin with the program in the Lab 5 presentation (slide 18 perhaps) which produces a PWM signal on D11 based on user input.

• Prompt the user to enter a value from 0 to 255. If an incorrect value is entered, display an error message and loop back to allow the user to again enter a value.

• If a correct value is entered, indicate that a PWM signal was sent to D11 and also display the duty cycle (as a percentage) and the analog (DC) voltage in a message to the serial monitor.

• The ouput for a valid input of 64 might look something like the following:

Sample program using ptm where the value for the high time of the pulse is read using serial communications void setup Serial begin 9600 Serial print ("Enter value for width of pulse (0 to 255) void loop if (Serial available reading until values entered long value Serial parse Int read input from keyboard Serial print ("Invalue read Serial printin value analogWrite 11 value Send ptna signal to Dll with D value /255 100 Serial print("VnEnter value for width of pulse 0 to 255 COM14 100 Send Enter value for width of pulse (0 to 255): Value read 25 Enter value for width of pulse (0 to 255) Value read 50 Enter value for width of pulse (0 to 255) Value read 75 Enter value for width of pulse (0 to 255) u v Auto scroll No line ending 9600 baud

Explanation / Answer

please find the answer as follows, first you need to modify the loop function for your exceptions as follows and keep setup function as it is.

void setup ()

{

serial.begin(9600);

serial.print("Enter a value for the width of the pulse (0 to 255): ");

}

void loop()

{

if(serial.available())

{

long value=serial.present();

if((value>255)&&(value<0))

{

serial.print("Entered value is not proper..please re check and enter proper value:");

setup();

loop();

}

else

{

serial.print(" Value read =");serial.println(value);

analogWrite(l1,value);

serial.print(" Enter value for width of pulse (0 to 255); ");

}
}

}

int main(void)

{

setup();

loop();

return 0

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote