christianlykke9 / Beomote

Bang & Olufsen Remote Library for Arduino
36 stars 15 forks source link

Execute command at certain IR syntax #5

Open Chickenthief90 opened 4 years ago

Chickenthief90 commented 4 years ago

What a nice way to get B&O IR into an Arduino! I already managed to use the SerialDump sketch to read the IR commands send by my Beo6. The irPin is connected to the IR jack on my Beosystem3 together with a GND connection.

Is it possible to use this library for executing Arduino commands at certain IR command?

For example: If I would send "Light + 0" from my Beo6, I want to make the Arduino put digital pin 4 HIGH. (Basic example, what I am working on is being able to control my Hue lights/scenes from the Beo6 remote)

My knowledge of Arduino coding is proving insufficient for this type of engineering. Any help would be very much appreciated

Chickenthief90 commented 4 years ago

With some trial and error I managed to get the Arduino to do what I want, control a digital pin whenever a specified command has been sent from the Beo6.

For now I have used the following code: `#include "Beomote.h"

int irPin = 10;

void setup() { Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT);

Beo.initialize(irPin); }

void loop() { BeoCommand cmd;

if (Beo.receive(cmd)) { Serial.print("LINK: "); Serial.println(cmd.link, DEC); Serial.print("ADDRESS: "); Serial.println(cmd.address, DEC); Serial.print("COMMAND: "); Serial.println(cmd.command, DEC); Serial.println(" ");

if ((cmd.link == 0) && (cmd.address == 27) && (cmd.command == 15)) {
  Serial.println("LIGHT OFF");
  Serial.println(" ");
  digitalWrite(LED_BUILTIN, HIGH);
  delay(200);
  digitalWrite(LED_BUILTIN, LOW);
}

if ((cmd.link == 0) && (cmd.address == 27) && (cmd.command == 16)) {
  Serial.println("LIGHT CINEMA");
  Serial.println(" ");
}

if ((cmd.link == 0) && (cmd.address == 27) && (cmd.command == 17)) {
  Serial.println("LIGHT WORK");
  Serial.println(" ");
}

if ((cmd.link == 0) && (cmd.address == 27) && (cmd.command == 18)) {
  Serial.println("LIGHT CHILL");
  Serial.println(" ");
}

}

}`

It might be a little mess but I have just started learning Arduino :-)

christianlykke9 commented 4 years ago

You should take a look at https://create.arduino.cc/projecthub/iotsky/controlling-a-philips-hue-via-a-arduino-b56620.

You can definitely use this library for executing commands when receiving IR-commands from you Bang & Olufsen remote. That is what I originally designed it for :-)

It looks like the Arduino Yun is using the same processor (the same clock speed as Uno) so I think you should be able to translate B&O ir commands to Philips Hue commands and it looks like you have already managed to implement a simple control structure to handle incoming IR commands.

Christian