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

Please help. This is should be simple for someone with a better understanding of

ID: 3814645 • Letter: P

Question

Please help. This is should be simple for someone with a better understanding of programming but I cannot figure out what I need to change

Write a C++ program for the Arduino UNO where the user can enter the pulse width in MICROSECONDS (1500, for example) and class Servo will be used to send the pulse to pin D10 to control a servo (causing it to rotate to a certain new orientation/position). I need to write this program which will allow a user to input a pulse width value between 1100-1900 microseconds and the output will cause a potentiometer to turn to corresponding values between 0 and 180 degrees.

This is the set up I have so far but it does not work correctly.

Global Variables /*Write a C++ program (Program 8C) for the Arduino UNO where the user can enter the pulse width in a (1500 for example) and class Servo will be used to send the pulse to pin D10 to control a servo (causing it to rotate to a certain new orientation/position). include Servo servoLeft servoRight. int value 0; float Duty cycle 0.000 float DCV 0.000 void setup Serial begin (9600) Serial print ("Enter a value for the width of the pulse IN MILISECONDS: pin Mode (10, OUTPUT) //servo Left. attach (10) void loop reading until values entered if (Serial available float value Serial parseInt read input from keyboard Serial print ("Invalue read Serial println (value); servoLeft.writeMicroseconds (value) else Serial write ("In Value Entered Serial println (value) analogwrite (10, value); SEND PWM signal to D11 with D value 255 Serial write ("PiM signal sent to D10 "); servoLeft. detach

Explanation / Answer

Input is (ms) : micronsecond ranging from 1100 - 1900.

Output is (dgr) : degree from 0 - 180

Basically, we need to map 1100 to 1900 range into 0 to 180 degree.

formula is : dgr = ((ms - 1100) * 9) / 40

Apply this in your code and it will work fine with your board.

Explanation : 1900 - 1100 = 800 and 180 - 0 = 180 to map 180 in the range of 800, need to multiply with (180/800) = (9/40).

Note : Always check the input whether it is between 1100 to 1900 or not. If not, please ask cunsumer to enter again or return from the code.