This page last changed on Apr 12, 2015 by igors.

hi.
I'm new to OpenRemote and would really appreciate some help.

I created 1 device LED1:
Name command = PowerOn
Protocol = Serial
COM Port = COM7
Data rate (bps) = 9600
Command = p (returns "ON" string)

Name command = PowerOFF
Protocol = Serial
COM Port = COM7
Data rate (bps) = 9600
Command = c (returns "OFF" string)

Name command = Status
Protocol = Serial
COM Port = COM7
Data rate (bps) = 9600
Command = Y (My controller returns(print) "on7" string if led is on and "off7" if off.)

New sensor led7
command = Status
Type = custom
name:
ON=on7
OFF=off7

New switch
name = sw led
sensor = led7
commandon = PowerOn
commandoff = PowerOFF

code Arduino nano

void setup() {
  Serial.begin(9600);
  pinMode(7, OUTPUT); 
  digitalWrite(7, LOW); 


}

void loop() {

  
  if (Serial.available()) {
    char c1 = Serial.read();
    
    
  switch (c1) {
  case 'p': {  
        digitalWrite(7, HIGH);
 
        Serial.print("on7\r\n");
      }
    break;
  case 'c': {  
        digitalWrite(7, LOW); 

         Serial.print("off7\r\n");
      }
    break;

  }


      int sw17 = digitalRead(7);
    if ((c1 == 'Y') && (sw17 == HIGH)) {
		Serial.print("on7\r\n");
	} else if ((c1 == 'Y') && (sw17 == LOW)) {
		Serial.print("off7\r\n");
        }

  }

}

When you press the switch there is no reaction. Please tell me how to do

I Igor, you can take a look at this thread

http://www.openremote.org/pages/viewpage.action?pageId=23597161&focusedCommentId=23597635#comment-23597635

Its not for Arduino, but for Raspberry Pi. But you might get the idea.

Hope this helps

Posted by jsanjur at Apr 18, 2015 17:05
Document generated by Confluence on Jun 05, 2016 09:32