Get Help
Infrared LED
Sparki has an Infrared LED. It is used to send information to other Sparkis like a remote control by rapidly blinking invisible infrared light.How It Works
Infrared remotes work by sending codes via flashing lights. These lights flash really fast; Sparki’s infrared LED flashes 38,000 times a second. By changing the amount of time between each flash, Sparki can send a burst that is meant to be a 1 or a 0, known as bits. Sparki sends these flashes until an entire code has been sent. Specifically, Sparki uses the NEC infrared code protocol.Using the Part
With the basic Sparki code in place, you can send infrared codes using this command:
1 |
sparki.sendIR(code); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
/******************************************* Infrared LED Send Code example Sparki has an infrared LED. You can use it to communicate with other Sparkis and other devices that use infrared remote controls. Other Sparkis can receive the code using sparki.readIR(); This example has Sparki sending a code every second. The code increases each time by 1. When the code reaches 255, the biggest number it can send, it goes back to zero and starts all over again. ********************************************/ #include <Sparki.h> // include the sparki library void setup() { } int code = 0; void loop() { sparki.sendIR(code); code = code + 1; // increase code by 1 // set code back to 0 if it goes over 255 - the highest number sendIR can send if(code = 255){ code = 0; } delay(1000); // wait one second } |