Hi,
I need to split a working but wired project on one arduino so it runs across two mcu's. Could I have some advice on ble and feasibility?
At present I have a red and a green LED that flash alternately. I have a "speed up' button and a 'slow down' button on ISR's that change the flash interval.
I need exactly this but the green led on one mcu and the red on another. I would like the buttons on a key fob device, not a smart phone app.
I was thinking using bluno ble's. I am a near-beginner. I am thinking of a master key fob mcu and two slave LED mcu's.
How do I chop my existing code, and is there a good learning resource? Most of what I can find is an app controlling one mcu.
Here is my code. Thanks so much in advance. Hope I've got these tags right. Al.
#include <MsTimer2.h>
const int Red = 5;
const int Green = 6;
const int upBtnPin = 2;
const int downBtnPin = 3;
const int Quickest = 100;
const int Slowest = 10000;
int Interval = 500;
int IntervalStep = 100;
//int noLED = Red;
//int buttonStateUp = 0;
//int buttonStateDown = 0;
void flash() {
static boolean output = HIGH;
digitalWrite(Red, output);
digitalWrite(Green, !output);
output = !output;
}
void setup() {
pinMode(5, OUTPUT); //RED One
pinMode(6, OUTPUT); //GREEN one
pinMode (upBtnPin, INPUT);
pinMode (downBtnPin, INPUT);
attachInterrupt(0, upPin_ISR, CHANGE);
attachInterrupt (1, downPin_ISR, CHANGE);
MsTimer2::set(Interval, flash); // 500ms period
MsTimer2::start();
}
void loop() {
}
void upPin_ISR ()
{
//upBtnState = digitalRead(upBtnPin);
if (Interval+IntervalStep <= Slowest )
{
Interval = Interval + IntervalStep;
MsTimer2::set(Interval, flash);
MsTimer2::start();
}
}
void downPin_ISR ()
{
//downBtnState = digitalRead(downBtnPin);
if (Interval-IntervalStep >= Quickest )
{
Interval = Interval - IntervalStep;
MsTimer2::set(Interval, flash);
MsTimer2::start();
Physwiz:
I was thinking using bluno ble's. I am a near-beginner. I am thinking of a master key fob mcu and two slave LED mcu's.
First question is why do you need more than 1 Arduino - the total task is certainly within the scope of any Arduino board.
Perhaps you want the red and green LEDs to be in different places? How far apart? The distance will affect the choice of wireless.
Even if there is a need for two Arduinos to allow the LEDs to be in different places it is not obvious why you would need a third Arduino. Couldn't either the red or green Arduino also receive the key-fob signals?
I have never used BLE so I don't know how feasible it would be with three Arduinos. Regular Bluetooth does not lend itself to that as it is a 1 to 1 system.
If I was creating a wireless system requiring more than two Arduinos (and if the distance was suitable) I would use nRF24L01+ wireless modules.
Another possibility might be ESP8266 or ESP32 WiFi modules. They can be programmed with the Arduino IDE. However they are 3.3 volt modules and they have fewer I/O pins.
Hi Robin2,
I need to take my setup into any room and stick one LED to a wall, one to the other and control their flash interval. Wired isn't workable because of the need to set it up quickly without there being a trip hazard. Distance will be <5 metres max. It may be used by people without a mobile phone. I think BLE supports multiple slaves. I've no experience of FSK radio.
Kind Regards,
Al.
Hi Robin,
Thanks for this. I'm looking at your program MultiTxAckPayload.ino that you uploaded in this thread on March 18th 2017. Two transmitters and one receiver. Is this the kind of setup you're thinking of?
Regards, Al.
Physwiz:
Thanks for this. I'm looking at your program MultiTxAckPayload.ino that you uploaded in this thread on March 18th 2017. Two transmitters and one receiver. Is this the kind of setup you're thinking of?
You would only need the ackPayload feature if the slaves need to send data back to the master. If you don't need that ability then you can just use a multiple of the receive program in my first example.
Your Reply #2 does not give me any grounds for thinking that more than two Arduinos would be needed.
The nRF24 modules are much more sophisticated than FSK wireless. They have a lot of error checking as standard.