/* * SimpleSender.cpp * * Demonstrates sending IR codes in standard format with address and command * An extended example for sending can be found as SendDemo. * * Copyright (C) 2020-2021 Armin Joachimsmeyer * armin.joachimsmeyer@gmail.com * * This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote. * * MIT License * * Angepasst am 06.04.2021 */#include <Arduino.h>
/* * Define macros for input and output pin etc. */#include "PinDefinitionsAndMore.h"
//#define SEND_PWM_BY_TIMER//#define USE_NO_SEND_PWM
#include <IRremote.h>
void setup() { pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
// Just to know which program is running on my Arduino Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
/* * The IR library setup. That's all! */ IrSender.begin(IR_SEND_PIN, ENABLE_LED_FEEDBACK); // Specify send pin and enable feedback LED at default feedback LED pin
Serial.print(F("Ready to send IR signals at pin ")); Serial.println(IR_SEND_PIN);}
/* * Set up the data to be sent. * For most protocols, the data is build up with a constant 8 (or 16 byte) address * and a variable 8 bit command. * There are exceptions like Sony and Denon, which have 5 bit address. */uint16_t sAddress = 0x10;uint16_t sCommand = 0x1AF;uint8_t sRepeats = 4;
void loop() { /* * Print current send values */
// Results for the first loop to: Protocol=NEC Address=0x102 Command=0x34 Raw-Data=0xCB340102 (32 bits) //IrSender.sendSony(sAddress, sCommand, sRepeats);
// delay(3000); // delay must be greater than 5 ms (RECORD_GAP_MICROS), otherwise the receiver sees it as one long signal //sCommand+=1; if (Serial.available()) { int Test = Serial.readString().toInt(); int inByte = sCommand; inByte++; sCommand = inByte; Serial.println(String(inByte)); IrSender.sendSony(sAddress, inByte, sRepeats);
Serial.println(); Serial.print(F("Send now: address=0x")); Serial.print(sAddress, HEX); Serial.print(F(" Zahl=")); Serial.print(inByte, DEC); Serial.print(F(" command=0x")); Serial.print(sCommand, HEX); Serial.print(F(" repeats=")); Serial.print(sRepeats); Serial.println(); Serial.println(F("Send Sony with 12bit address")); Serial.flush(); }}