9 years, 1 month ago.

Serial Problem KL25z -

Hello Everybody!

I am having a problem with this code: (couldn´t load it)

-starts here--- AnalogIn; Interupts with adxl;

  1. include "mbed.h"

AnalogIn ain(PTB3); DigitalOut led1(LED1); led green DigitalOut led2(LED2); led red Ticker t1; timer to send data Serial pc(USBTX, USBRX);

void HandlerT1(void); void rx_Handler(void);

volatile bool STATUS = true; char test = 0; char teste = 0;

int main(){

Setup pc.baud(9600); pc.printf("main"); t1.attach(&HandlerT1, 0.001); pc.attach(&rx_Handler, pc.RxIrq); led1=0; led2=0;

while(1){ wait(0.5);debug pc.printf("Waiting for 2"); pc.putc(teste);

while(teste==2){

pc.printf("STATUS = \t%d\n",STATUS);debuging pc.putc(1);debug

if (STATUS == true){ led1 = 0; led2 = 1; pc.printf("timerRED");debug } else if(STATUS == false){ led1 = 1; led2 = 0; pc.printf("timergren");debug

}else { pc.printf("ERROR"); } } } }

/*void HandlerT1(void){ pc.putc(8); STATUS=(!STATUS); return; }*/

void rx_Handler(void){ test = pc.getc(); teste = test; pc.putc(test); pc.printf("calledme"); }

ends here--

It should enter the second while loop when I send a '2' from the computer, but it doens´t..

What did I do wrong? Besides that, any another mistakes i made or tips you can give me?

First question here =)

Thank you

Thiago

1 Answer

9 years, 1 month ago.

Hi,

How about changing

while(teste==2){

to

while (teste=='2') {

moto

Accepted Answer

Thank you! Helped me a lot!

posted by Thiago . 24 Feb 2015