/* IRremoteESP8266: IRsendDemo - demonstrates sending IR codes with IRsend. Version 1.1 January, 2019 Based on Ken Shirriff's IrsendDemo Version 0.1 July, 2009, Copyright 2009 Ken Shirriff, http://arcfn.com An IR LED circuit *MUST* be connected to the ESP8266 on a pin as specified by kIrLed below. TL;DR: The IR LED needs to be driven by a transistor for a good result. Suggested circuit: https://github.com/crankyoldgit/IRremoteESP8266/wiki#ir-sending Common mistakes & tips: * * Don't just connect the IR LED directly to the pin, it won't have enough current to drive the IR LED effectively. * * Make sure you have the IR LED polarity correct. See: https://learn.sparkfun.com/tutorials/polarity/diode-and-led-polarity * * Typical digital camera/phones can be used to see if the IR LED is flashed. Replace the IR LED with a normal LED if you don't have a digital camera when debugging. * * Avoid using the following pins unless you really know what you are doing: * * Pin 0/D3: Can interfere with the boot/program mode & support circuits. * * Pin 1/TX/TXD0: Any serial transmissions from the ESP8266 will interfere. * * Pin 3/RX/RXD0: Any serial transmissions to the ESP8266 will interfere. * * ESP-01 modules are tricky. We suggest you use a module with more GPIOs for your first time. e.g. ESP-12 etc. */ #include <M5StickCPlus.h> #include <IRremoteESP8266.h> #include <IRsend.h> const uint16_t kIrLed = 9; // 赤外LEDが接続されたピン番号 IRsend irsend(kIrLed); // Set the GPIO to be used to sending the message. // Example of data captured by IRrecvDumpV2.ino uint16_t photoshot[99] = {3488, 1740, 438, 424, 438, 1302, 440, 422, 438, 424, 440, 422, 440, 422, 440, 422, 438, 424, 438, 424, 438, 424, 438, 424, 438, 426, 438, 424, 438, 1302, 440, 422, 442, 422, 440, 424, 438, 424, 438, 424, 442, 420, 438, 1304, 438, 1304, 440, 1302, 438, 424, 438, 424, 438, 424, 438, 424, 438, 1302, 440, 424, 440, 1302, 440, 422, 438, 424, 440, 422, 440, 1302, 438, 1304, 438, 424, 438, 424, 438, 1304, 438, 1302, 438, 424, 438, 424, 462, 1278, 464, 1278, 464, 1278, 462, 1280, 460, 1280, 464, 398, 464, 398, 438 }; // PANASONIC 40040E14667C uint16_t recording[99] = {3490, 1738, 440, 424, 438, 1304, 438, 424, 438, 424, 438, 424, 438, 424, 438, 424, 438, 424, 438, 424, 438, 424, 438, 424, 438, 424, 438, 424, 438, 1302, 440, 424, 442, 422, 438, 424, 438, 424, 438, 424, 438, 424, 438, 1302, 442, 1302, 438, 1302, 440, 424, 440, 424, 438, 424, 438, 424, 438, 1302, 442, 420, 442, 1302, 438, 424, 438, 422, 442, 422, 438, 424, 440, 1302, 438, 1302, 438, 424, 438, 424, 438, 1302, 442, 1300, 440, 424, 440, 422, 440, 1302, 440, 424, 462, 1278, 464, 400, 464, 398, 464, 1278, 464 }; // PANASONIC 40040E143329 void setup() { M5.begin(115200); M5.Lcd.fillScreen(BLUE); irsend.begin(); } void loop() { // Serial.println("NEC"); // irsend.sendNEC(0x00FFE01FUL); // Serial.println("Sony"); // irsend.sendSony(0xa90, 12, 2); // 12 bits & 2 repeats M5.update(); if (M5.BtnA.wasReleased()) { irsend.sendRaw(photoshot, 99, 38); // Send a raw data capture at 38kHz. M5.Lcd.fillScreen(YELLOW); } else if (M5.BtnB.wasReleased()) { irsend.sendRaw(recording, 99, 38); // Send a raw data capture at 38kHz. M5.Lcd.fillScreen(RED); } delay(150); M5.Lcd.fillScreen(BLUE); // Serial.println("a Samsung A/C state from IRrecvDumpV2"); // irsend.sendSamsungAC(samsungState); // delay(2000); }