You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@USAGE: A function that produce an analog voltage on a non-PWM pin.
@PARAMETERS: takes non-PWM pin number and value between 0 [LOW] to 255 [HIGH]
@Description: The voltage value taking from a pin is the average value of the period.
Using that we can get an average value from a non-PWM enabled arduino pin by manipulating the duty cycle of the HIGH and LOW voltage with a very small period 100 microsecond.
*/
void PWMWrite(int pin, int volt){
int timeHIGH = ((volt/255) * 100 ) * 100; //getting the percentage of the HIGH voltue and multiplying it by 100 MICROSECOND
float timeLOW = 100 - timeHIGH;
while(1){ //Infinit loop to supply the needed voltage without stopping.