TurnOnFujitsuAC.ino 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2017 Jonny Graham, 2018 David Conran
  2. #ifndef UNIT_TEST
  3. #include <Arduino.h>
  4. #endif
  5. #include <IRremoteESP8266.h>
  6. #include <IRsend.h>
  7. #include <ir_Fujitsu.h>
  8. const uint16_t kIrLed = 4; // ESP8266 GPIO pin to use. Recommended: 4 (D2).
  9. IRFujitsuAC ac(kIrLed);
  10. void printState() {
  11. // Display the settings.
  12. Serial.println("Fujitsu A/C remote is in the following state:");
  13. Serial.printf(" %s\n", ac.toString().c_str());
  14. // Display the encoded IR sequence.
  15. unsigned char* ir_code = ac.getRaw();
  16. Serial.print("IR Code: 0x");
  17. for (uint8_t i = 0; i < ac.getStateLength(); i++)
  18. Serial.printf("%02X", ir_code[i]);
  19. Serial.println();
  20. }
  21. void setup() {
  22. ac.begin();
  23. Serial.begin(115200);
  24. delay(200);
  25. // Set up what we want to send. See ir_Fujitsu.cpp for all the options.
  26. Serial.println("Default state of the remote.");
  27. printState();
  28. Serial.println("Setting desired state for A/C.");
  29. ac.setCmd(kFujitsuAcCmdTurnOn);
  30. ac.setSwing(kFujitsuAcSwingBoth);
  31. ac.setMode(kFujitsuAcModeCool);
  32. ac.setFanSpeed(kFujitsuAcFanHigh);
  33. ac.setTemp(24); // 24C
  34. }
  35. void loop() {
  36. // Now send the IR signal.
  37. Serial.println("Sending IR command to A/C ...");
  38. #if SEND_FUJITSU_AC
  39. ac.send();
  40. #else // SEND_FUJITSU_AC
  41. Serial.println("Can't send because SEND_FUJITSU_AC has been disabled.");
  42. #endif // SEND_FUJITSU_AC
  43. printState();
  44. delay(5000);
  45. }