Ciaran O'Malley
/
LAB_2_1_SerialComms
Lab 2.1
Revision 1:d8d13815a008, committed 2020-07-27
- Comitter:
- ciaranom
- Date:
- Mon Jul 27 18:13:23 2020 +0000
- Parent:
- 0:72aa19bb1aec
- Commit message:
- Lab Question 2.1 - Serial Communications
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Jun 20 11:19:11 2020 +0000 +++ b/main.cpp Mon Jul 27 18:13:23 2020 +0000 @@ -6,18 +6,20 @@ float brightness = 0.0; int main() { - pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n"); + pc.printf("Press '^' to turn LED1 brightness up, 'v' to turn it down\n"); while(1) { - char c = pc.getc(); - if((c == '^') && (brightness < 0.5)) { - brightness += 0.01; + char a = pc.getc(); //a is a single value taken from the last cahracter from the input stream (stdin)- the keyboard + pc.putc(a); //Outputs the character C on the stdout - TeraTerm in this case - Prints input from keyboard + + + if((a == '^') && (brightness < 0.5)) { //Code unly increases to LEDs 50% LEDs max capacity as not to risk damaging the device + brightness += 0.01; //increases brigness up in increaments of 0.01 - 50 total led = brightness; } - if((c == 'v') && (brightness > 0.0)) { + //if((a == 'v') && (brightness > 0.0)) { brightness -= 0.01; led = brightness; } } -} \ No newline at end of file