@konacurrents I have the IR Remote sensor, and I can now receive IR signals.
Cannot send IR
But I cannot send any IR signals (just repeating what was received). This is the volume on 3 or my remotes. I'm using the M5Atom button (which is Button B) to make do the IRSend command.
I found the IRremote
and IRSender
objects. I'm also using the Port B of my I2S using pins 33 and 32.
I'm trying to send what was printed from receiving the IR:
Send with: IrSender.sendSamsung(0x7, 0x7, <numberOfRepeats>);
By calling:
IrSender.sendSamsung(0x7, 0x7, 1);
Any ideas?
My sample program is below:
/******************************************************************************
Please connect to Port B,Use IR Unit to receive and test infrared receiving
and transmitting 请连接端口B,使用红外单元接收和测试红外接收和发射.
*/
#include <Arduino.h>
//#include <M5Core2.h>
#include <M5StickCPlus.h>
#include <IRremote.hpp>
#include <IRSend.hpp>
// I2S (middle port on Atom's port extender I2s driver)
int ir_recv_pin = 33; // set the input pin. 设置引脚
int ir_send_pin = 32;
#define DELAY_AFTER_SEND 2000
#define DELAY_AFTER_LOOP 500
//!see https://forum.arduino.cc/t/irremote-sending-samsung-code-but-not-working/1312154
#define IR_RECEIVE_PIN ir_recv_pin
#define IR_SEND_PIN ir_send_pin
void setup() {
Serial.begin(115200);
Serial.println();
M5.begin();
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
delay(DELAY_AFTER_LOOP);
IrSender.begin(IR_SEND_PIN);
Serial.print(F("Ready to receive IR signals of protocols: "));
printActiveIRProtocols(&Serial);
//Serial.println(F("at pin " STR(IR_RECEIVE_PIN));
}
void loop() {
//Serial.println("loop");
M5.update(); // Read the press state of the key. 读取按键 A, B, C 的状态
if (M5.BtnA.wasReleased())
{
// If the button A is pressed. 如果按键 A 被按下
Serial.println("A");
}
else if (M5.BtnB.wasReleased())
{
// If the button B is pressed. 如果按键
// B 被按下,
Serial.println("B");
//! seems to be the main button.. B
//! lets send the volume UP
//Protocol=Samsung Address=0x7 Command=0x7 Repeat gap=46750us Raw-Data=0xF8070707 32 bits LSB first
Serial.println("IrSender.sendSamsung(0x7, 0x7, 1)");
IrSender.sendSamsung(0x7, 0x7, 1);
IrReceiver.restartAfterSend(); // Is a NOP if sending does not require a timer.
delay(DELAY_AFTER_SEND);
}
else if (M5.BtnB.wasReleasefor(700))
{
// The button B is pressed for 700ms. 按键 B 按下
// 700ms,屏幕清空
Serial.println("b 700");
}
/*
Check if received data is available and if yes, try to decode it.
Decoded result is in the IrReceiver.decodedIRData structure.
E.g. command is in IrReceiver.decodedIRData.command
address is in command is in IrReceiver.decodedIRData.address
and up to 32 bit raw data in IrReceiver.decodedIRData.decodedRawData
*/
if (IrReceiver.decode()) {
/*
Print a summary of received data
*/
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
Serial.println(F("Received noise or an unknown (or not yet enabled) protocol"));
// We have an unknown protocol here, print extended info
IrReceiver.printIRResultRawFormatted(&Serial, true);
IrReceiver.resume(); // Do it here, to preserve raw data for printing with printIRResultRawFormatted()
} else {
IrReceiver.resume(); // Early enable receiving of the next IR frame
IrReceiver.printIRResultShort(&Serial);
IrReceiver.printIRSendUsage(&Serial);
}
Serial.println();
}
delay(DELAY_AFTER_LOOP);
}