Go Down

Topic: interruptions for arduino bluetooth (Read 564 times) previous topic - next topic

rosa_ally

Hello.
I've been fooling around with an arduino Bluetooth board that I bought recently and I'm having a lot of trouble with the interruptions.
I'm trying to communicate my pocket pc with the board... The pocket pc sends information to the board and depending on what the board reads through the port it is supposed to act one way or another. (right now I'm working with leds... lets say if the board receives a 1 the leds light up following a certain function, if it receives a 2 then the function is paused ...) Ideally what I would want to do is create an interruption every time the board receives bytes through its serial port. Does anybody know if this is impossible?? Any ideas???
I'm not sure I'm explaining myself to clearly.. basically what I'm trying to do is have  something like:
void loop () {
 clead(0,255,0);
 clead(1,0,0)
}
This look should go on forever until de board receives bytes trough the serial port?
Thanks for your time!!!

rosa_ally

...please ... somebody... heeeeelp  :'(

bigengineer

#2
Aug 23, 2007, 09:25 pm Last Edit: Aug 23, 2007, 09:26 pm by bigengineer Reason: 1
I am not sure what you want exactly and if you need interrupts for that. But in the loop you can check if there are bytes in the serial buffer with Serial.available(). this returns the number of bytes in the buffer which you can read with Serial.read. If the buffer is empty, nothing happens, only loop is running.  If there is something in the buffer, you can call a function depending on the value that you read.

Daniel

hey

yes your question is not clear enough, can you describe in point form what steps the software has to take?

D

rosa_ally

The problem is solved. I thought that interruptions were gonna be the answer to my problem but I've found another way to solve it.

I was using 'fors' inside the loop so even if data was available on the serial, I couldn't manage it until one of the fors was finished (and they were very long fors). Now, just calling the method inside the fors a lot of times (the same number of times than the fors counter), I can watch the serial constantly.

Thanks for your time!

Go Up