Serial communication test.
This program is test of LPC1114 serial communication.
When you use Mac, it is as follows.
1)Run the Terminal.app.
2)ls /dev/tty.usb*
When you use USB-Serial converter and RS232C level conveter, It is displayed with /dev/tty.usbserial-xxxxxxxxx.
When you use LPC1114FN28 mbed board from USB cable, It is displayed with /dev/tty.usbmodemfdxxxx.
3)Run the screen command.
screen /dev/tty.usbXXXXXXXX.
4)Press 'u' to turn LED1 brightness up,'d' to turn it down.
Case1:LPC1114FN28 mbed board.
Case2:LPC1114 CPU stand alone.
Revision 0:ef61dfc4f518, committed 2015-05-06
- Comitter:
- ImageWriter
- Date:
- Wed May 06 13:16:40 2015 +0000
- Commit message:
- Test program for LPC1114 serial communication.
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 |
diff -r 000000000000 -r ef61dfc4f518 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed May 06 13:16:40 2015 +0000 @@ -0,0 +1,40 @@ +#include "mbed.h" +/* Serial Dimmer 20150506 ImageWriter +/ This program is test of LPC1114 serial communication. +/ When you use Mac, it is as follows. +/ 1)Run the Terminal.app. +/ 2)ls /dev/tty.usb* +/ When you use USB-Serial converter and RS232C level conveter, +/ It is displayed with /dev/tty.usbserial-xxxxxxxxx. +/ When you use LPC1114FN28 mbed board from USB cable, +/ It is displayed with /dev/tty.usbmodemfdxxxx. +/ 3)Run the screen command. +/ screen /dev/tty.usbXXXXXXXX. +/ 4)Press 'u' to turn LED1 brightness up,'d' to turn it down. +*/ + +//Serial pc(USBTX, USBRX); // tx, rx +Serial pc(dp16, dp15); //LPC1114 + +//PwmOut led(LED1); +PwmOut led(dp1); //LPC1114's PWMout is dp1 and dp2. + +float brightness = 0.0; + +int main() { + pc.printf("Press 'u' to turn LED1 brightness up, 'd' to turn it down\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; + } + pc.printf("%c:%5.2f\r\n",c,brightness); + + } +}
diff -r 000000000000 -r ef61dfc4f518 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed May 06 13:16:40 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8ab26030e058 \ No newline at end of file