nRF wireless control LEDs

Hi all,

I am new to using Arduino and would like to have some help/guidance on my currently project. My project aim is to control one RGB led, one infrared red led and light bulb wirelessly. Up to this point, I have managed to get the light bulb working but not sure how to continue as I am new to the code.

My idea is to add two more cases inside the void loop() as RGB and IR leds. Also, I think I know how to make the changes to MenuScreen to add the extra display.

However, I am struggling with modifying void RadioComms() and void DriveBulb() or any other parts of code that I have missed out…

Cheers

Arduino_Code_RF_Slave_Device.ino (4.87 KB)

OLED_Arduino_CodeV3_with_RF_MASTER_CODE.ino (43.3 KB)

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :slight_smile:

You have allowed the program to get much too complicated before making sure it works. As far as I can see that Master program won’t even compile because you are trying to define the function DriveBulb() inside the function setup().

Have a look at this Simple nRF24L01+ Tutorial. Get the wireless communication working reliably before you add any other functionality because wireless problems can be very difficult to debug.

From what you say you just want communication between 2 devices so why use code that is designed for more than that? I have made my examples as simple as possible.

…R

Thanks Tom and Robin for you replies.

I will make sure to paste my code next time... Sorry for the inconvenience...

It is working atm with the light bulb.

Yes, that's because I am planning to have more slaves than one.

Cheers

engineer_abc:
Yes, that's because I am planning to have more slaves than one.

I'm a bit confused by what you mean for the roles of master and slave. At the moment your master code is much longer so that suggests to me it is the one that is doing all the work after receiving commands from the other devices. Is that correct?

Is it practical for the master to make a call to each slave in turn - perhaps 5 times per second? If so the system in my second example is a simple way to achieve that and I have an example for using that in a multi-device system.

...R

The master code is like a controller which selects a PWM level and send it to the slave which is connecting with a light bulb.

And now I wanted to have not just a light bulb but a RGB/IR leds connecting to the slave device.

Thanks for the reply, Robin.

engineer_abc:
The master code is like a controller which selects a PWM level and send it to the slave which is connecting with a light bulb.

Give some examples of the data you want to send to a slave.

Would it be easier to have all the background data in the slave program and then have a short master program that only needs to send a short message to tell the slave what to do?

And you did not respond to the question in my last paragraph in Reply #4

…R

Thanks for your reply, Robin.

The data I want to send is only the PWM level to the slave so that I can control the brightness.

Yes, I believe so and I think for now most of the code in master is focusing on the display of the screen.

Sorry about that... Yes, I think it is practical to make a call to slave 5 times to second or even less.

Cheers.

engineer_abc:
The data I want to send is only the PWM level to the slave so that I can control the brightness.

Does that mean that, for example, any one message will just be a single byte containing a value between 0 and 255? If not, please give more detail.

Yes, I think it is practical to make a call to slave 5 times to second or even less.

Have you tried any of my examples? If you just need one-way communication then the first example should be fine. If you need two-communication then the second example will be the simplest.

By the way my suggestion for 5-times-per-second was assuming the need for two-way communication where the master needed to collect data from several slaves.

...R