/*☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄
☄ ☄
☄ ☘ DATOS GENERALES: ☄
☄ NOMBRE: Uso básico módulo infrarrojo. ☄
☄ FECHA: 05 de marzo de 2024. ☄
☄ VERSIÓN: 1.0. ☄
☄ ☄
☄ AUTOR: M. en C. Esli Castellanos Berján. ☄
☄ E-MAIL: [email protected]. ☄
☄ COMPAÑÍA: Universidad de Colima - Facultad de Telemática. ☄
☄ ☄
☄ uC: Atmega328p. ☄
☄ Nombre: ESP32-S. ☄
☄ ☄
☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄
☄ ☄
☄ ☘ DESCRIPCIÓN DEL PROGRAMA: ☄
☄ Arquitectura de software para recibir valores hexadecimales desde ☄
☄ un control remoto mediante el módulo receptor. ☄
☄ ☄
☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄
☄ ☄
☄ ☘ NOTAS: ☄
☄ ☄
☄ ☄
☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄☄*/
#include <IRremote.h>
#define IR_PIN 3
#define LED_INDICATOR 9
void setup ( void ) {
Serial.begin ( 9600 );
IrReceiver.begin( IR_PIN, ENABLE_LED_FEEDBACK );
}
uint32_t obtener_boton_presionado () {
if ( IrReceiver.decode ( ) ) { /*~ Si hay un valor recibido. ~*/
IrReceiver.resume ( ); /*~ Limpia el buffer permitiendo mostrar el siguiente número recibido, en caso de no usar está función simplemente se queda el último valor recibido.~*/
Serial.println ( IrReceiver.decodedIRData.decodedRawData, HEX ); /*~ Mostrar el valor en hexadecimal. ~*/
return IrReceiver.decodedIRData.decodedRawData; /*~ Retorna el valor recibido, en caso de necesitarlo.~*/
}
}
void loop ( void ) {
obtener_boton_presionado ( ); /*~ Función que imprime el valor hexadecimal del botón presionado. ~*/
delay (100);
}