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

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
subhrajitmitra
Date:
Mon Apr 22 10:24:28 2013 +0000
Commit message:
same execution using python and c

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 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
diff -r 000000000000 -r 8826f8e474c9 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Apr 22 10:24:28 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7e6c9f46b3bd
\ No newline at end of file