Hi, I am trying to connect two mbeds (both FRDM-KL25Z) together using serial connection. The code for the first one is :
main.cpp
#include "mbed.h"
Serial myarduino(PTD3, PTD2);
Serial btserial(PTC4, PTC3);
DigitalOut myled(LED1);//////////
int main()
{
char data;
btserial.baud(9600);
myarduino.baud(9600);
while(1){
data = 'u';
//data = btserial.getc();
myarduino.printf("%c",data);
wait(0.2);
while(data == 'u') {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}}
}
This mbed is meant to send the letter 'u' to the second mbed. The code for the second mbed is:
testmbedconnection.cpp
#include "mbed.h"
Serial freescale(PTD3, PTD2);
Serial btserial(PTC4, PTC3);
DigitalOut myled(LED1);//////////
int main()
{
char data;
btserial.baud(9600);
freescale.baud(9600);
while(1){
if(freescale.readable())
{
data = freescale.getc();
if(data == 'u') {
myled = 1;
wait(0.2);
myled = 0;
wait(0.2);
}}}
}
Ideally, i set the LED on mbed 2 to blink when data received is u. This doesn't work. I commented out the condition and set a new condition for the LED to blink if "if(freescale.readable()) " is true. That worked. It means my mbed 1 is readable but the data is not being sent.
Please any idea what i'm doing wrong? All help would be appreciated. Ps my connections are Rx1 to Tx2 and Tx1 to Rx2 so I'm almost certain that's not the issue.
Hi, I am trying to connect two mbeds (both FRDM-KL25Z) together using serial connection. The code for the first one is :
main.cpp
This mbed is meant to send the letter 'u' to the second mbed. The code for the second mbed is:
testmbedconnection.cpp
Ideally, i set the LED on mbed 2 to blink when data received is u. This doesn't work. I commented out the condition and set a new condition for the LED to blink if "if(freescale.readable()) " is true. That worked. It means my mbed 1 is readable but the data is not being sent. Please any idea what i'm doing wrong? All help would be appreciated. Ps my connections are Rx1 to Tx2 and Tx1 to Rx2 so I'm almost certain that's not the issue.