Liam McHale
/
labq1sat
Lab instrumentation Q1
Diff: main.cpp
- Revision:
- 0:4e4b546e1d74
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jul 18 08:25:23 2020 +0000 @@ -0,0 +1,17 @@ +#include"mbed.h" + +Serial pc(USBTX,USBRX);//tx,rx +PwmOut led(LED1); +float brightness=0.0; +int main(){ + pc.printf("Press'u'toturnLED1brightnessup,'d'toturnitdown\n"); + while(1){ + char c=pc.getc(); + if((c=='u')&&(brightness<0.5)){ + brightness+=0.01; + led = brightness; + }if((c=='d')&&(brightness>0.0)){ + brightness-=0.01; + led=brightness; } + } + } \ No newline at end of file