tomasz_gurajek

Dependencies:   mbed

main.cpp

Committer:
t00204088
Date:
2020-08-01
Revision:
0:f5e4c88886a5

File content as of revision 0:f5e4c88886a5:

#include "mbed.h"
Serial pc(USBTX, USBRX); // tx, rx //defines an object called pc of class serial ,and point it at the USB port
PwmOut led(LED1);                  //Pwm stands for puls with modulations and led is an object of clas PwmOut
float brightness = 0.0;            //brightness is a variable of type float (whitch means real number 
int main() {
 pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n"); //output a massage at the start ,once
 while(1) {                        //do"forever"
 char c = pc.getc();               //defines a variable c of type char and sets it to a character recived from TeraTerm
 if((c == 'u') && (brightness < 0.5)) {
     pc.putc('^');                 //press U to show on teraterm ^
 brightness += 0.01;               //equivalent to brightness=brightness + 0.01
 led = brightness;
 }
 if((c == 'd') && (brightness > 0.0)) {
     pc.putc('v');                 //press D to show on teraterm v
 brightness -= 0.01;
 led = brightness;
 }
 }
}