Domenico Vitale / Mbed 2 deprecated PWM

Dependencies:   mbed

PWM_with_led.cpp

Committer:
domemort
Date:
2021-11-03
Revision:
0:4460e57975af

File content as of revision 0:4460e57975af:

#include "mbed.h"
Serial pc(USBTX, USBRX);
PwmOut  LED(D6);
DigitalIn bottone(USER_BUTTON);
float ADCdata;

int main(){
     pc.printf("ADC Data Values...\n\r");
     while(1){
     LED.period(1);
     if (bottone==0){
     LED=0.3;
     } else LED=0.7;
       ADCdata=LED*3.3f;
       wait(0.5);
       pc.printf("%1.3f\n\r", ADCdata);
         if(ADCdata<1.65f){
            LED=1;}
        else LED=0;
     }
}