Besoin d'aide : Shield GSM et décodage DTMF

Bonsoir,

J'aimerais commander des relais depuis un smartphone en utilisant un shield GSM et un arduino uno, avec des tonalités DTMF. Comme sur cette video : arduino y sim 900 dtmf decode - YouTube

J'utilise le code suivant :

#include "SIM900.h"
#include <SoftwareSerial.h>
//We don't need the http functions. So we can disable the next line.
//#include "inetGSM.h"
#include "sms.h"
#include "call.h"

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to check if an incoming call is from an authorized
//number and in this case, send to this number an SMS with the value
//of a digital input.

//We have to create the classes for SMSs and calls.
CallGSM call;
SMSGSM sms;

char number[20];
byte stat=0;
int value=0;
char value_str[5];
char DTMF_char='_';
int count=0;
int ledPin=13;      // the number of the LED pin
int led=12;


void setup() 
 
{
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);
  //Serial connection.
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(9600))
    Serial.println("\nstatus=READY");
  else Serial.println("\nstatus=IDLE");
  //Enable DTMF detection for SIM900
  call.SetDTMF(1);
};

void loop() 
{
  //Chekcs status of call
  stat=call.CallStatusWithAuth(number,0,0);
  //If the incoming call is from an authorized number
  //saved on SIM in the positions range from 1 to 2.
  if(stat==CALL_INCOM_VOICE_AUTH){
    //Pick up the call.
    call.PickUp();
  }
    while(stat==CALL_ACTIVE_VOICE){
    for (int k=0; k<100; k++)
    {
      DTMF_char=call.DetDTMF();
      if(DTMF_char!='-')            
        Serial.println(DTMF_char);
      if(DTMF_char!='1') 
      digitalWrite(led, HIGH);
       if(DTMF_char!='2') 
      digitalWrite(led, LOW);
       if(DTMF_char!='3') 
      digitalWrite(ledPin, HIGH);
       if(DTMF_char!='4') 
      digitalWrite(ledPin, LOW);
             
    }
    stat=call.CallStatus();
    
   
  }
  delay(1000);
};

Lorsque j'ouvre le moniteur série je vois bien les codes DTMf s'afficher lors de l'appui sur les touches du clavier, mais il ne se passe rien en sortie de l'arduino.

J'utilise ce type de syntaxe dans le code :
if(DTMF_char!='1')
digitalWrite(led, HIGH);

car je voudrais que quand le code DTMF est 1 alors on passe la sortie 12 à l'état haut.

mais je ne sais pas du tout si c'est approprié !

Bref, j'ai besoin d'aide des spécialistes ...

Merci,

Christophe,

bonjour,
tu es sure de ton coup avec != pour moi, c'est différent de
avec == ca marcherait sans doute mieux

Ok, j'ai merdé dans le copier coller ... je viens de tester avec == et = mais rien n'y fait .

Ca marche !!!!!

#include "SIM900.h"
#include <SoftwareSerial.h>
//We don't need the http functions. So we can disable the next line.
//#include "inetGSM.h"
#include "sms.h"
#include "call.h"

//To change pins for Software Serial, use the two lines in GSM.cpp.

//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.

//Simple sketch to check if an incoming call is from an authorized
//number and in this case, send to this number an SMS with the value
//of a digital input.

//We have to create the classes for SMSs and calls.
CallGSM call;
SMSGSM sms;

char number[20];
byte stat=0;
int value=0;
char value_str[5];
char DTMF_char='_';
int count=0;
int ledPin=13;      // the number of the LED pin
int led=12;


void setup() 
 
{
  pinMode(ledPin, OUTPUT);
  pinMode(led, OUTPUT);
  digitalWrite(ledPin, HIGH);
  digitalWrite(led, HIGH);
  //Serial connection.
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(9600))
    Serial.println("\nstatus=READY");
  else Serial.println("\nstatus=IDLE");
  //Enable DTMF detection for SIM900
  call.SetDTMF(1);
};

void loop() 
{
  //Chekcs status of call
  stat=call.CallStatusWithAuth(number,0,0);
  //If the incoming call is from an authorized number
  //saved on SIM in the positions range from 1 to 2.
  if(stat==CALL_INCOM_VOICE_AUTH){
    //Pick up the call.
    call.PickUp();
  }
    while(stat==CALL_ACTIVE_VOICE){
    for (int k=0; k<100; k++)
    {
      DTMF_char=call.DetDTMF();
      if(DTMF_char!='-')            
        Serial.println(DTMF_char);
      if(DTMF_char=='1') 
      digitalWrite(led, HIGH);
       if(DTMF_char=='2') 
      digitalWrite(led, LOW);
       if(DTMF_char=='3') 
      digitalWrite(ledPin, HIGH);
       if(DTMF_char=='4') 
      digitalWrite(ledPin, LOW);
             
    }
    stat=call.CallStatus();
    
   
  }
  delay(1000);
};

Il y as encore surement moyen de simplifier mais ca fonctionne.

MERCI !

Christophe,