Skip to content

Instantly share code, notes, and snippets.

@chapuzzo
Created August 13, 2021 07:10
Show Gist options
  • Save chapuzzo/9e4516050212b26f610e84b11fd1a00b to your computer and use it in GitHub Desktop.
Save chapuzzo/9e4516050212b26f610e84b11fd1a00b to your computer and use it in GitHub Desktop.
Tinkering with ventiators and IR signals
/*
* Fan protocol tester
* light should toggle
*/
#include <Arduino.h>
/*
* Set library modifiers first to set output pin etc.
*/
#include "PinDefinitionsAndMore.h"
//#define IR_OUTPUT_IS_ACTIVE_LOW
#define IRSND_IR_FREQUENCY 36000
#define IRSND_PROTOCOL_NAMES 1 // Enable protocol number mapping to protocol strings - requires some FLASH.
#include <irsndSelectMain15Protocols.h>
/*
* After setting the definitions we can include the code and compile it.
*/
#include <irsnd.c.h>
IRMP_DATA irsnd_data;
void setup()
{
Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL) || defined(ARDUINO_attiny3217)
delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!
#endif
#if defined(ESP8266)
Serial.println(); // to separate it from the internal boot output
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRMP));
irsnd_init();
irmp_irsnd_LEDFeedback(true); // Enable send signal feedback at LED_BUILTIN
#if defined(ARDUINO_ARCH_STM32)
Serial.println(F("Ready to send IR signals at pin " IRSND_OUTPUT_PIN_STRING)); // the internal pin numbers are crazy for the STM32 Boards library
#else
Serial.println(F("Ready to send IR signals at pin " STR(IRSND_OUTPUT_PIN)));
#endif
int cmds[] = {0x400, 0x47F, 0x408, 0x408, 0x408};
for (int i = 0; i<sizeof(cmds)/sizeof(cmds[0]); i++){
irsnd_data.protocol = IRMP_FAN_PROTOCOL;
irsnd_data.address = 0x0;
irsnd_data.command = cmds[i];
irsnd_data.flags = 1;
irsnd_send_data(&irsnd_data, true);
irsnd_data_print(&Serial, &irsnd_data);
}
}
void loop(){}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment