Created
August 22, 2017 23:31
-
-
Save abdullahseba/26ddf3e54f56e5c69b521534e414a0f7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool telSetbyStatus = true; | |
bool telMuteStatus = true; | |
bool paSetbyStatus = true; | |
bool paMuteStatus = true; | |
int telSetBy = A0; | |
int telMute = A1; | |
int paSetBy = 2; | |
int paMute = 3; | |
int lrRly1 = 4; | |
int lrRly2 = 5; | |
void setup() { | |
pinMode(telSetBy, OUTPUT); | |
pinMode(telMute, OUTPUT); | |
pinMode(paSetBy, OUTPUT); | |
pinMode(paMute, OUTPUT); | |
pinMode(lrRly1, OUTPUT); | |
pinMode(lrRly2, OUTPUT); | |
digitalWrite(telSetBy, LOW); | |
digitalWrite(telMute, LOW); | |
digitalWrite(paSetBy, LOW); | |
digitalWrite(paMute, HIGH); | |
digitalWrite(lrRly1, LOW); | |
digitalWrite(lrRly2, LOW); | |
Serial.begin(9600); | |
Serial.println("Ready"); | |
} | |
void loop() { | |
Serial.setTimeout('1'); | |
while (Serial.available()) { | |
String data = Serial.readString(); | |
if (data.indexOf("telephone -e") >= 0) { | |
telephonesSetBy(); | |
} | |
if (data.indexOf("telephone -m") >= 0) { | |
telephonesMute(); | |
} | |
if (data.indexOf("public-address -e") >= 0) { | |
publicAddressSetBy(); | |
} | |
if (data.indexOf("public-address -m") >= 0) { | |
publicAddressMute(); | |
} | |
} | |
} | |
void telephonesSetBy() { | |
if (telSetbyStatus == true) { | |
digitalWrite(telSetBy, HIGH); | |
telSetbyStatus = false; | |
Serial.println("Telephone On"); | |
} else { | |
digitalWrite(telSetBy, LOW); | |
telSetbyStatus = true; | |
Serial.println("Telephone Off"); | |
} | |
} | |
void telephonesMute() { | |
if (telMuteStatus == true) { | |
digitalWrite(telMute, HIGH); | |
telMuteStatus = false; | |
Serial.println("Telephone Unmuted"); | |
} else { | |
digitalWrite(telMute, LOW); | |
telMuteStatus = true; | |
Serial.println("Telephone Muted"); | |
} | |
} | |
void publicAddressSetBy() { | |
if (paSetbyStatus == true) { | |
digitalWrite(paSetBy, HIGH); | |
paSetbyStatus = false; | |
Serial.println("PA On"); | |
} else { | |
digitalWrite(paSetBy, LOW); | |
paSetbyStatus = true; | |
Serial.println("PA Off"); | |
} | |
} | |
void publicAddressMute() { | |
if (paMuteStatus == true) { | |
digitalWrite(paMute, LOW); | |
paMuteStatus = false; | |
Serial.println("PA Unmuted"); | |
} else { | |
digitalWrite(paMute, HIGH); | |
paMuteStatus = true; | |
Serial.println("PA Muted"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment