add digital read

This commit is contained in:
Shannon Sterz 2016-01-20 19:40:28 +01:00
parent 3a376ebc7e
commit e1601ce1a2

View file

@ -34,9 +34,9 @@ void decodeMessage() {
switch (cmd) {
//case 80: break;
case 81: setMode(val[0], pin); break;
case 82: digitalW(val[0], pin) break;
//case 83: break;
case 81: setMode(val[0], pin); break;
case 82: digitalW(val[0], pin); break;
case 83: digitalR(pin); break;
//case 84: break;
//case 85: break;
//case 86: break;
@ -46,7 +46,7 @@ void decodeMessage() {
default: break;
}
} else if(cmd] == 90) {
} else if(cmd == 90) {
com = true;
setMode(0, pin);
@ -62,7 +62,7 @@ void decodeMessage() {
void setMode(uint8_t val, int pin) {
if(pin == -1) { if(debug) Serial.println("badpin"); return; }
if(pin == -1) { Serial.println("badpin"); return; }
if (val == 0) {
pinMode(pin, OUTPUT);
@ -74,7 +74,7 @@ void setMode(uint8_t val, int pin) {
void digitalW(uint8_t val, int pin) {
if(pin == -1) { if(debug) Serial.println("badpin"); return; }
if(pin == -1) { Serial.println("badpin"); return; }
pinMode(pin, OUTPUT);
if(val == 0) {
@ -85,13 +85,23 @@ void digitalW(uint8_t val, int pin) {
}
void digitalR(int pin) {
if(pin == -1) { Serial.println("badpin"); return; }
pinMode(pin, INPUT);
int digraw = digitalRead(pin);
String m = String(pin + '::' + digraw);
Serial.println(m);
}
void sendRCTristate (uint8_t val[], int pin) {
if(pin == -1) { if(debug) Serial.println("badpin"); return; }
if(pin == -1) { Serial.println("badpin"); return; }
String triStateCode = "";
RCSwitch rc = RCSwitch();
mySwitch.enableTransmit(pin);
rc.enableTransmit(pin);
for(int i = 0; i < 6; i++)
{
@ -103,11 +113,6 @@ void sendRCTristate (uint8_t val[], int pin) {
triStateCode.toUpperCase();
triStateCode.toCharArray(triState, triStateCode.length() + 1);
controlRCOutlets(triState);
rc.sendTriState(triState);
Serial.println("RC-Tristate send!");
}
void controlRCOutlets(const char* sCodeWord) {
mySwitch.sendTriState(sCodeWord);
delay(1000);
}
}