Strings from Char help


hi everybody,

i have code turns on led 13 when dtmf tone of 5 selected.  works great expand code either 3 or 4 digit dtmf code received turn led off.  100 turn on led , 1000 turn led off.

i've been experimenting strings can not figure out how turn thischar string can maybe use readstring.indexof send commands led.

any ideas? or guidance.



 
code: [select]
//dtmf remote
//led pin 13
//audio in a0

#include <dtmf.h>

int sensorpin = a0;
int led = 13;
float n=128.0;

float sampling_rate=8926.0; // sampling rate in hz

dtmf dtmf = dtmf(n,sampling_rate); // instantiate dtmf library
//the number of samples taken , sampling rate.


void setup(){
  pinmode(led, output);     
  serial.begin(115200);
 
}
int nochar_count = 0;
float d_mags[8];




void loop()
{
  char thischar;
 
  /* while(1) */

  dtmf.sample(sensorpin);
  dtmf.detect(d_mags,512);
 
  for(int = 0;i < 8;i++) {
    d_mags[i] /= n;
  }
 
  thischar = dtmf.button(d_mags,20.);

// led on receive dtmf "5"
if(thischar == '5') {
  digitalwrite(led, high);
}

if(thischar == '0') {
  digitalwrite(led, low);
}

  if(thischar) {
    serial.print(thischar);
    nochar_count = 0;

}
}


string stringone =  string(thischar);


Arduino Forum > Using Arduino > Programming Questions > Strings from Char help


arduino

Comments