The IR Puck can mimic arbitrary infrared remote controls. Built on the Puck IOT platform.

Dependencies:   Puck IRSender mbed

The IR Puck is a puck that can mimic arbitrary infrared remote controls. This is useful for controlling things like TVs, radios, airconditioners, window blinds, and just about anything and everything that can be otherwise be controlled by a regular remote control.

A tutorial for the IR Puck is available on GitHub.

Tutorials and in-depth documentation for the Puck platform is available at the project's GitHub page

main.cpp

Committer:
sigveseb
Date:
2014-07-23
Revision:
5:3642c0af497e
Parent:
4:24d9873936e6
Child:
8:260888851644
Child:
13:f016a0bc4a7d

File content as of revision 5:3642c0af497e:

#include "mbed.h"
#include "IR.h"

#define LOG_LEVEL_VERBOSE
#include "Puck.h"

Puck* puck = &Puck::getPuck();

const UUID IR_SERVICE_UUID = stringToUUID("bftj ir         ");
const UUID HEADER_UUID     = stringToUUID("bftj ir header  ");
const UUID ONE_UUID        = stringToUUID("bftj ir one     ");
const UUID ZERO_UUID       = stringToUUID("bftj ir zero    ");
const UUID PTRAIL_UUID     = stringToUUID("bftj ir ptrail  ");
const UUID PREDATA_UUID    = stringToUUID("bftj ir predata ");
const UUID CODE_UUID       = stringToUUID("bftj ir code    ");


void onIRCodeWrite(uint8_t* value) {
    LOG_INFO("Going to fire IR code...\n");
    fireIRCode(puck->getCharacteristicValue(HEADER_UUID),
               puck->getCharacteristicValue(ONE_UUID), 
               puck->getCharacteristicValue(ZERO_UUID),
               puck->getCharacteristicValue(PTRAIL_UUID),
               puck->getCharacteristicValue(PREDATA_UUID),
               puck->getCharacteristicValue(CODE_UUID));
    LOG_INFO("Fire complete!\n");
}


int main() {
    puck->addCharacteristic(IR_SERVICE_UUID, HEADER_UUID, 4);
    puck->addCharacteristic(IR_SERVICE_UUID, ONE_UUID, 4);
    puck->addCharacteristic(IR_SERVICE_UUID, ZERO_UUID, 4);
    puck->addCharacteristic(IR_SERVICE_UUID, PTRAIL_UUID, 2);
    puck->addCharacteristic(IR_SERVICE_UUID, PREDATA_UUID, 2);
    puck->addCharacteristic(IR_SERVICE_UUID, CODE_UUID, 2);
    puck->init(0xABBA);
    puck->onCharacteristicWrite(CODE_UUID, onIRCodeWrite);
    while (puck->drive());
}