From d6fc89518a6a3a21d53823d83d2a8cf64957d678 Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Mon, 28 Mar 2022 19:52:23 +0000 Subject: [PATCH] Added test interrupt code. --- firmware/trigger_firmware/trigger_firmware.ino | 32 +++++++++++++++++++++++++++++--- 1 files changed, 29 insertions(+), 3 deletions(-) diff --git a/firmware/trigger_firmware/trigger_firmware.ino b/firmware/trigger_firmware/trigger_firmware.ino index a76cd54..996053d 100644 --- a/firmware/trigger_firmware/trigger_firmware.ino +++ b/firmware/trigger_firmware/trigger_firmware.ino @@ -1,14 +1,32 @@ +/* There was a help from these two pages: +https://forum.arduino.cc/t/connect-nrf24l01-to-esp32/678710/4 +https://electropeak.com/learn/wireless-communication-w-arduino-and-nrf24l01/ +*/ + +#include <RF24_config.h> +#include <nRF24L01.h> +#include <RF24.h> +#include <printf.h> + #include<WiFi.h> -#define IN_TRIGGER 18 -#define OUT_TRIGGER 19 +#define IN_TRIGGER 17 +#define OUT_TRIGGER 16 + +RF24 radio(22, 21); // CE, CSN + +const byte address[6] = {'R','E','C','V', '1'}; +char dataToSend[4] = "TRG"; void IRAM_ATTR isr() { digitalWrite(OUT_TRIGGER, HIGH); + radio.write( &dataToSend, sizeof(dataToSend) ); delay(1); digitalWrite(OUT_TRIGGER,LOW); } + + void setup() { // put your setup code here, to run once: @@ -16,13 +34,21 @@ WiFi.mode(WIFI_OFF); btStop(); + + radio.begin(); + radio.openWritingPipe(address); + radio.setPALevel(RF24_PA_MAX); + //radio.setDataRate( RF24_250KBPS ); + pinMode(IN_TRIGGER, INPUT_PULLUP); pinMode(OUT_TRIGGER, OUTPUT); attachInterrupt(IN_TRIGGER, isr, RISING); + } void loop() { // put your main code here, to run repeatedly: - +//radio.write( &dataToSend, sizeof(dataToSend) ); +// delay(5000); } -- Gitblit v1.9.3