Go Down

Topic: Reading chars and storing into an array (!) (Read 843 times) previous topic - next topic


I'm playing with DTMF tones, using a MT8870 I decode tones to digital signals (binary code) and with some arduino code I parse it.

At this moment my loop function is:
Code: [Select]
void loop() {
irqState = digitalRead(STD); //Get the first trigger tone
if (irqState == 1) {
char code = mapKey();

The thing is: I receive each decoded tone by triggering the irqState, So if I send 123 (three tones) I get 123, that is very nice!!! But now I want to 'store' it into an array to compare it later (to do some remote control stuff).

How can I do this?

Sorry for my english  :~


Jan 29, 2013, 04:27 am Last Edit: Jan 29, 2013, 04:41 am by LarryD Reason: 1
Code: [Select]
//Lets say you have an array:
char dtmf [20]
int i = 0;

//some code

// some code
         irqState = digitalRead(STD);                //Get the first trigger tone
         if (irqState == 1)
               dtmf[++i]= mapKey();

// lets say an # starts iteration code thought dtmf[0] to dtmf[maximum] to process through the values
// don't forget to set i = 0 when you are ready to start capturing again.

} // END of loop

No technical PMs.
The last thing you did is where you should start looking.


Code: [Select]
                dtmf[++i]= mapKey();
When i starts at 0, where are you storing the first value, Larry? Not in the 0 spot, where it belongs.
The art of getting good answers lies in asking good questions.


your solution works like a boss in my project, thanks!!!


Jan 29, 2013, 11:42 pm Last Edit: Jan 29, 2013, 11:44 pm by lloyddean Reason: 1
I would think you'd want to start by placing the first item at 'dtmf[0]' and not 'dtmf[1]'

Try ...

Code: [Select]

dtmf[i++]= mapKey();


Yep! I did that change to start in 0 position.


Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131