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

main.cpp

Committer:
subhrajitmitra
Date:
2013-04-22
Revision:
0:8826f8e474c9

File content as of revision 0:8826f8e474c9:

#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)

*/