Please i need someone to tell me why this is not working: I'm having a sketch that receives a command via serial (Messenger Library) and afterwards pulses a IR Led corresponding to the received message.
The following works fine:
// Create the callback function
void messageReady()
{
msgToProcess = 0;
if (message.checkString("on"))
blinkLed(on, sizeof(on)/sizeof(long));
if (message.checkString("off"))
blinkLed(off, sizeof(off)/sizeof(long));
if (message.checkString("white"))
blinkLed(white, sizeof(white)/sizeof(long));
if (message.checkString("red"))
blinkLed(red, sizeof(red)/sizeof(long));
if (message.checkString("green"))
blinkLed(green, sizeof(green)/sizeof(long));
if (msgToProcess == 0)
{
Serial.println("UNKNOWN CMD");
message.readInt();
}
}
But as soon as i add one more message like
if (message.checkString("blue"))
blinkLed(blue, sizeof(blue)/sizeof(long));
the whole sketch stops working but the IR Leds always blinks (i know this because i'm using Pin 13 as Output pin which has a normal led attached on my board) but without any data sent to Arduino via Serial connection.
But all the entries appear to be integer multiples of ten.
A fairly quick statistical analysis of the distribution of of the pulse lengths, and a further short look up table could reduce your pulse tables to byte size or smaller.
Just thinking aloud.
hmm ok
But it's very hard to reprogram this sketch if it's not really clear where the problem is...
IS there a different possiblity for implementing my needs? (maybe with different library / without library?)
I can't imagine it's not possible reacting on let's say 24 different messages that Arduino should get via serial.
What is the result of the array size calculation?
The probem is very easy to solve, in several different ways.
Some will require lots of changes, some very few.
Probably the simplest short term fix would be to change all the longs into unsigned ints.
PaulS:
Of course it is. Just get rid of all those arrays.
How would you implement it without using arrays?
How would you implement the serial communication part (with messenger library or something different?)
AWOL:
Probably the simplest short term fix would be to change all the longs into unsigned ints.
One more time.
Change the 'long' array declarations to 'unsigned int'.
Change the sizeof calculation to use unsigned int instead of long (a macro would be useful here).
Job done, for now.
AWOL:
One more time.
Change the 'long' array declarations to 'unsigned int'.
Change the sizeof calculation to use unsigned int instead of long (a macro would be useful here).
Job done, for now.
ok i did this now.
Now i had a bit more free space and could add 5 more IF's.
But now i'm again stuck only 79 free..