Joseph Forde
/
JF_Serial_communications_1
Serial_communications_1
Revision 4:eabf5656c755, committed 2020-07-28
- Comitter:
- jforde
- Date:
- Tue Jul 28 11:42:09 2020 +0000
- Parent:
- 3:4e35f0d99e64
- Commit message:
- Serial_communications_1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Feb 21 20:30:41 2014 +0000 +++ b/main.cpp Tue Jul 28 11:42:09 2020 +0000 @@ -1,14 +1,24 @@ -#include "mbed.h" +#include "mbed.h" //Preprocessor Directives + // Declarations +Serial pc(USBTX, USBRX); // tx, rx +PwmOut led(LED1); -DigitalOut myled(LED1); -DigitalOut myled2(LED2); -int main() { +float brightness = 0.0; +int main() { //instructions in main () function + pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\n"); + while(1) { - myled = 1; - myled2 = 0; - wait(0.5); - myled = 0; - myled2 = 1; - wait(0.5); + char c = pc.getc(); //Reads a character from keyboard + if((c == 'u') && (brightness < 0.5)) { + brightness += 0.01; + led = brightness; + pc.putc('^'); // Writes a character ('^') to the standard output + } + if((c == 'd') && (brightness > 0.0)) { + brightness -= 0.01; + led = brightness; + pc.putc('v'); // Writes a character ('v') to the standard output + } } } +
--- a/mbed.bld Fri Feb 21 20:30:41 2014 +0000 +++ b/mbed.bld Tue Jul 28 11:42:09 2020 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/078e4b97a13e +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file