![](/media/cache/profiles/abdcaa8e62fa9a0e2e86a0564d11bde4.50x50_q85.jpg)
here the python code (as in comment line) and c code are shown through which FRDM-KL25Z board can be used as independent usb-uart device.l
Diff: main.cpp
- Revision:
- 0:8826f8e474c9
diff -r 000000000000 -r 8826f8e474c9 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 22 10:24:28 2013 +0000 @@ -0,0 +1,60 @@ +#include "mbed.h" +Serial pc(USBTX,USBRX); +DigitalOut led1(LED_RED); +DigitalOut led2(LED_GREEN); +DigitalOut led3(LED_BLUE); +int main() +{ +pc.printf("hello world\n");//you can print through function("pc.printf") described on mbed library of C +while(1) + { + printf("RED led blinks\n");//you can print through C's own print function + led1=0; + led2=1; + led3=1; + wait(0.5); + printf("GREEN led blinks\n");//you can print through C's own print function + led1=1; + led2=0; + led3=1; + wait(0.5); + printf("BLUE led blinks\n");//you can print through C's own print function + led1=1; + led2=1; + led3=0; + wait(0.5); + } +} + +/* +#python code for LED and "hello world" over serial +#compile thid code and generate ".bin" file and download it to your FRDM-KL25Z flash +#from http://pymbed.appspot.com/ online python compiler +import mbed +import sys + +led1 = mbed.DigitalOut('LED_RED') +led2 = mbed.DigitalOut('LED_GREEN') +led3 = mbed.DigitalOut('LED_BLUE') +pc = mbed.Serial('PTA2', 'PTA1') +pc.baud(9600) +pc.writeable() +pc.puts('Hello world \n')#you can print through function("puts") described on mbed library of python +while 1: + print('RED led blinks\n')#you can print through python's own print function + led1.write(0) + led2.write(1) + led3.write(1) + sys.wait(500) + print('GREEN led blinks\n')#you can print through python's own print function + led1.write(1) + led2.write(0) + led3.write(1) + sys.wait(500) + print('BLUE led blinks\n')#you can print through python's own print function + led1.write(1) + led2.write(1) + led3.write(0) + sys.wait(500) + +*/ \ No newline at end of file