tomasz_gurajek

Dependencies:   mbed

Committer:
t00204088
Date:
Sat Aug 01 10:16:27 2020 +0000
Revision:
0:f5e4c88886a5
tomasz_gurajek

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t00204088 0:f5e4c88886a5 1 #include "mbed.h"
t00204088 0:f5e4c88886a5 2 Serial pc(USBTX, USBRX); // tx, rx //defines an object called pc of class serial ,and point it at the USB port
t00204088 0:f5e4c88886a5 3 PwmOut led(LED1); //Pwm stands for puls with modulations and led is an object of clas PwmOut
t00204088 0:f5e4c88886a5 4 float brightness = 0.0; //brightness is a variable of type float (whitch means real number
t00204088 0:f5e4c88886a5 5 int main() {
t00204088 0:f5e4c88886a5 6 pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n"); //output a massage at the start ,once
t00204088 0:f5e4c88886a5 7 while(1) { //do"forever"
t00204088 0:f5e4c88886a5 8 char c = pc.getc(); //defines a variable c of type char and sets it to a character recived from TeraTerm
t00204088 0:f5e4c88886a5 9 if((c == 'u') && (brightness < 0.5)) {
t00204088 0:f5e4c88886a5 10 pc.putc('^'); //press U to show on teraterm ^
t00204088 0:f5e4c88886a5 11 brightness += 0.01; //equivalent to brightness=brightness + 0.01
t00204088 0:f5e4c88886a5 12 led = brightness;
t00204088 0:f5e4c88886a5 13 }
t00204088 0:f5e4c88886a5 14 if((c == 'd') && (brightness > 0.0)) {
t00204088 0:f5e4c88886a5 15 pc.putc('v'); //press D to show on teraterm v
t00204088 0:f5e4c88886a5 16 brightness -= 0.01;
t00204088 0:f5e4c88886a5 17 led = brightness;
t00204088 0:f5e4c88886a5 18 }
t00204088 0:f5e4c88886a5 19 }
t00204088 0:f5e4c88886a5 20 }