Hello to all,
forgive the banality of my question , but just now I’m approaching with these arguments .
As a first experience I would simply turn on an LED on Arduino via openhab .
For now using windows but acquired the necessary knowledge I would spend all of raspberry .
I opehab configured with a simple switch .
I defined the following item :
Switch Luce1 “Luce 1” (gSolaio, gLuci)
String Node5 “Nodo 1” (All) { serial=“COM4”, autoupdate=“false” }
I called these RULE:
rule “accensione luce”
when
Item Luce1 changed
then
sendCommand(Node1, “1”)
end
This however is the sketch of Arduino:
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
Serial.begin(9600);
}
void loop() {
int ser=0;
if (Serial.available() )
{ ser=Serial.read();
if(ser==‘1’)
{
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
Serial.println(“ACCESO”);
}
else if (ser== ‘2’)
{
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
Serial.println(“SPENTO”);
}
}
unfortunately I can not make it work .
Noting also the serial monitor when I turn the switch on openhab not written anything .
I think the problem is due to the serial communication .
What’s wrong ?
I hope I was clear and I thank you in advance