Hello Im trying to get these nrf24l01 transceivers to dim an LED wirelessly for some reason NOTHING !
here is my Code
any Help would be great im out of ideas ?
[/c//-Transmitter
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int pot_pin = A5;
const byte address[6] = "00001";
RF24 radio(7,8);
// Set up nRF24L01 radio on SPI bus plus pins 7 & 8 (CE & CS)
int volts ;
void setup() {
radio.begin();
//radio.setPALevel(RF24_PA_LOW);
//radio.setDataRate(RF24_250KBPS);
radio.setChannel (75);//Set Channel from 0-127
radio.openWritingPipe(address[6]);
radio.stopListening();
pinMode(pot_pin, INPUT);
}
void loop() {
volts = map(analogRead(pot_pin),0,1024,0,254);
radio.write(&volts,sizeof(volts) );
delay(20);
}
code]
[code][
//Receiver
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int LED = 9;
byte address[6] = "00001";
RF24 radio(7, 8);
// Set up nRF24L01 radio on SPI bus plus pins 7 & 8 (CE & CS)
int volts ;
void setup() {
pinMode(LED, OUTPUT);
radio.begin();
//radio.setPALevel(RF24_PA_LOW);
//radio.setDataRate(RF24_250KBPS);
radio.setChannel (75);//Set Channel from 0-127
radio.openReadingPipe (0, address[6]);
radio.startListening ();
}
void loop() {
/*
digitalWrite(LED,HIGH);
delay(500);
digitalWrite(LED,LOW);
delay(500);
*/
if (radio.available()) {
radio.read(&volts, sizeof(volts));
//volts = map(volts, 0, 254, 0, 1023);
delay(50);
analogWrite(LED,volts);
}
}/code]
Put a Serial.begin(9600) in setup so that you can use a Serial.print to see what you are receiving. The serial port is your best troublshooting tool.
Use the examples in the simple rf24 tutorial to get the radios working and gain a better understanding of how they work.
This certainly won't work. Study the example code, and array indexing basics .
radio.openWritingPipe(address[6]);
radio.openReadingPipe (0, address[6]);
Im no pro with these radios . Im learning thoe
this is code I borrowed from somewhere do you have any Idea What I should change this to
radio.openReadingPipe (0, address[6]);
The examples linked in reply #1 show how to do it correctly.
address[6] is not defined, and is an illegal reference to memory that you do not own.
ok ill give it a shot ...Thanks
well That didn't work im just trying to dim an LED wirelessly ..how hard is that ? lol
What did you try and what were the results? "Didn't Work" is probably the most piss-poor problem statement you could have come up with.
363 posts and that is the best you can do ?
Please read and follow the directions in the "How to use this forum" post.
Robin2
June 10, 2019, 6:10am
10
bandmwhitt2013:
well That didn't work im just trying to dim an LED wirelessly ..how hard is that ? lol
That gives us no useful information from which to help you.
Have you tried the examples in this Simple nRF24L01+ Tutorial for which you were given the link in Reply #1 ?
Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.
The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work
...R