Last active
December 5, 2024 00:13
-
-
Save maagmirror/87d83c0c326ccc1bf817a0d6df9b5bb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <nRF24L01.h> | |
#include <RF24.h> | |
// Pines para CE y CSN | |
#define CE_PIN 4 | |
#define CSN_PIN 5 | |
// Inicializa el módulo nRF24L01 | |
RF24 radio(CE_PIN, CSN_PIN); | |
void setup() { | |
Serial.begin(115200); | |
// Inicializar nRF24L01 | |
if (!radio.begin()) { | |
Serial.println("Error al inicializar el nRF24L01"); | |
while (1); // Detener si no funciona | |
} | |
// Configurar el módulo | |
radio.setPALevel(RF24_PA_HIGH); // Potencia máxima | |
radio.setDataRate(RF24_250KBPS); // Velocidad baja para mayor alcance | |
Serial.println("Módulo nRF24L01 inicializado."); | |
} | |
void loop() { | |
for (int channel = startChannel; channel <= endChannel; channel++) { | |
// Cambiar al canal actual | |
radio.setChannel(channel); | |
// Enviar ruido en el canal | |
uint8_t noise[32] = {0xFF}; // Paquete de ruido (32 bytes) | |
radio.write(noise, sizeof(noise)); // Transmitir el paquete | |
Serial.printf("Transmitiendo ruido en canal %d (%.3f GHz)\n", channel, 2.400 + channel * 0.001); | |
delay(5); // Rápido cambio entre canales | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment