-
Notifications
You must be signed in to change notification settings - Fork 15
Help
The Spark Core is an tiny WiFi development kit. It is Arduino compatible and has built-in WiFi capability. More info on www.spark.io. It is based on the STM32F103CB microcontroller, hence the code in this repository should be compatible with other development kits based on the STM32F103CB.
This library allows to send IR (infrared) signals to emulate remote controls. Most TV, DVD player, SAT box, DVR, etc uses IR remote controls. This library can emulate the vast majority of those remote controls.
To use this library with the Spark Core, go on the Spark web IDE: https://www.spark.io/build, create a new app (by clicking the <> icon on the left) and then to the right of your first tab at the top, click the circle icon with a | in it. Name the new tab with the name of the .cpp file to add, in this case IRremote.cpp. Both the .cpp and .h tab will be added. Copy paste the whole content of each file into their respective tab in the Spark IDE. To make it easier to copy the whole file, select the file in github and click "Raw" button, select the whole text and copy to clipboard.
One example way to use the library to send a code: Connect an IR led anode (+) (the leg of the led which is the longest and which is on the side that does not have the flat part, see this diagram for help) to the D1 pin of the Spark Core. Then connect the cathode (-) of the led to a resistor of at least 100 ohms and connect the other end of the resistor to one of the ground (GND) pins of the Spark Core. In your .ino file (first tab, main file of your program), add a global variable IRsend irsend(D1);
to initialize the library to the pin D1. Then, in your code you can use any of the irsend.sendXXX() methods.
IR codes are made out of marks and spaces which corresponds to bits. A mark represents a 1 and a space represents a 0. Marks are defined by a duration in microsecond and a pulse frequency. Spaces are defined by a duration in microsecond. A mark is the action of pulsing the IR led at a specific frequency for a specific duration. In general the frequency is 38khz and the duration is somewhere between 400 and 5000 microsecond. A space is the action of turning off the IR led completely for a specific duration. The IR code is generally composed of 16 to 128 bits send using marks and spaces and usually with a space of a different duration in between bits called bit mark. Some devices have much longer IR codes such as air conditioners which can have codes of more than 800 bits. This is because the remote of air conditioners sends all of the settings every time (fan power, temperature, schedule, mode, etc) to make sure that the settings of the air conditioner unit is in sync with the remote control display. In general, IR codes have a special mark and space before sending the IR code to specify the beginning of the IR code transmission. This is called the header.