How to make a remote control system via DTMF Module+ GSM/GPR

Hello
Last time, I make a remote control LED by SMS via GSM/GPRS/GPS module.
But you know that SMS need a little time to be received. So we can't decide the delay time. We can't make a real-time control.
This time, I will try a new module "DTMF shield".
The preparatory work:
1 DTMF shield
2 GSM/GPRS/GPS module V3.0
3 Romeo board or arduino UNO with motor driver.
4 An audio cable
5 A platform
6 A full charge battery (7.4v)
You can plug these modules on the platform.
Hardware Connection:
1 Plug one side of audio cable into GSM module "speaker". The other to the DTMF module.
2 Connect GSM module driver: Pin 15,16,17(A1,A2,A3)
Sample code:
Code: Select all/*
DTMF.cpp - TEST code for DTMF library
*/
#include "dtmf.h"
int myDtmf;
DTMF dtmf;
int E1 = 5; //M1 Speed Control
int E2 = 6; //M2 Speed Control
int M1 = 4; //M1 Direction Control
int M2 = 7; //M1 Direction Control
void stop(void) //Stop
{
digitalWrite(E1,LOW);
digitalWrite(E2,LOW);
}
void advance(char a,char b) //Move forward
{
analogWrite (E1,a); //PWM Speed Control
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void back_off (char a,char b) //Move backward
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
void turn_L (char a,char b) //Turn Left
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void turn_R (char a,char b) //Turn Right
{
analogWrite (E1,a);
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
byte gsmDriverPin[3] = {
15,16,17};
void setup()
{
Serial.begin(9600);
for(int i=4;i<=7;i++) pinMode(i, OUTPUT);
pinMode(15,OUTPUT);
pinMode(16,OUTPUT);
pinMode(17,OUTPUT);
//Init the driver pins for GSM function
digitalWrite(17,HIGH);//Output GSM Timing
delay(1500);
digitalWrite(17,LOW);
digitalWrite(15,LOW);//Enable the GSM mode
digitalWrite(16,HIGH);//Disable the GPS mode
delay(2000);
delay(5000);
delay(5000);//call ready
Serial.println("ATS0=1"); //autopickup on first tone
}
void loop()
{
// Read DTMF codes one by one and print it on Serial
myDtmf = dtmf.getDTMF();
if(myDtmf != -1)
{
// Serial.println(myDtmf);
switch(myDtmf)
{
case 2://Move Forward
advance (250,250); //move forward in max speed
break;
case 8://Move Backward
back_off (250,250); //move back in max speed
break;
case 4://Turn Left
turn_L (150,150);
break;
case 6://Turn Right
turn_R (150,150);
break;
case 5:
stop();
break;
}
}
}
After you have uploaded the code and finish the connection.
Just need a phone call, you can control it.
Fortunately, it works finally. Although it still has some bugs, it works well for the testing.
This project is not only for the robots, but also the home automation. With some sensors, it can do more.