DTMF MT8870DS


Version
Download24
Stock
File Size1.10 KB
Create DateNovember 30, 2017
Download

//------------------
const int STQ = 3;
const int Q1 = 4;
const int Q2 = 5;
const int Q3 = 6;
const int Q4 = 7;

//-----------------

byte DeviceState;
const byte WAITING = 0;
const byte START_OF_TONE = 1;
const byte DURING_TONE = 2;
const byte END_OF_TONE = 3;
byte DTMFread;
//-----------------

void setup() {
pinMode(STQ, INPUT);
pinMode(Q4, INPUT);
pinMode(Q3, INPUT);
pinMode(Q2, INPUT);
pinMode(Q1, INPUT);
DeviceState = WAITING;
//============================
Serial.begin(115200);

}
void loop() {

byte StqState = digitalRead(STQ);
if((StqState==HIGH)&&(DeviceState==WAITING)){
DeviceState = START_OF_TONE;
// Serial.println("[");
DTMFread=0;
if(digitalRead(Q1)==HIGH){
DTMFread=DTMFread+1;
}
if(digitalRead(Q2)==HIGH){
DTMFread=DTMFread+2;
}
if(digitalRead(Q3)==HIGH){
DTMFread=DTMFread+4;
}
if(digitalRead(Q4)==HIGH){
DTMFread=DTMFread+8;
}

Serial.write("[");
Serial.print(DTMFread);
Serial.write("]");
DeviceState = DURING_TONE;

}

}

Be the first to comment

Leave a Reply

Your email address will not be published.


*