My Idea is to get all the Mirf code out of the way and put it in an #include/library file. The include file enable a simple way to share variables. I feel that a system like this would help a lot of people who don't want to spend the time to learn the ins and outs of the mirf library. Maniacbug if you read this pleas help, your code is the only thing I've got to work.
Here's an idea of what it would look like.
#include <EasyMirf.h>
void loop()
{
//radio setup
//number of the channel
int chan = 8;
//Number of received variables.
int rxCount = 6;
//Set or update received variables.
int rxVar[1] = buttonA;
int rxVar[2] = buttonB;
int rxVar[3] = buttonC;
boolean rxVar[4] = ledSwitch1;
boolean rxVar[5] = ledSwitch2;
char rxVar[6] = "hello world";
//Number of variables to be sent.
int txCount = 3;
//Variables to be sent
int tempurature = txVar[1];
int servoPos = txVar[2];
char "good by world" = txVar[3];
}
There's always a trade-off between simplicity and usability. If you think hiding everything in header files makes it easier to use, give it a shot. In my view, it's better to have clearly documented methods with well-defined behaviour. The RF24 primary public interface is all of 9 methods, along with plenty examples.
You can also try RF24Network. The helloworld_tx is pretty simple. 55 lines of code for a fully functional repeating-send node.
I've too haven't had any luck with the Mirf libraries,all of Maniacbug's examples work very well, now the challange is to send 2 or more sensor readings through the "message" string.
I was just thinking that a simple way for two arduinos to share variables would help many beginners get a jump start there projects and keep the code clutter to a minimum. Like a mirf lite. I know a lot of power would be sacrificed but most projects don't need to do more than share variables.
Thanks for your help, I'll figure it out eventually.
i've been working on that also, just managed to send the temperature from my remote board to my mega with an lcd display, now i'm trying to include the battery voltage also.
I was just thinking that a simple way for two arduinos to share variables would help many beginners get a jump start there projects and keep the code clutter to a minimum.
Not a bad idea. But that "code" you posted initially is garbage. At least, post something that has a snowballs chance of compiling.
joeyballard:
I was just thinking that a simple way for two arduinos to share variables would help many beginners get a jump start there projects and keep the code clutter to a minimum.
Ooohhh... It helps to state the problem and goals more clearly at the top. And to post truly compiling code too, as Paul points out. Anyway, now I understand. This is interesting. You'd want something that creates a shared address space between two sketches. In the background the system just hums away without the user noticing, and keeps the variables in sync.
I would implement this as a higher layer...
struct shared_vars_t
{
int counter;
unsigned long time;
};
shared_vars_t myvars;
RF24 radio(9,10);
RF24Syncro syncro(&radio);
void setup(void)
{
radio.begin();
syncro.begin(/* my node is */ 1);
syncro.synchronize(/* data */ myvars, /* with node */ 2);
}
void loop(void)
{
syncro.update();
syncro.time = millis();
Serial.println(syncro.counter);
}
maniacbug:
You'd want something that creates a shared address space between two sketches. In the background the system just hums away without the user noticing, and keeps the variables in sync.
Yes, this is exactly what I meant, if it's not too much trouble to make something like this it would save me a lot of time. I'm not quite advanced enough to make it myself or I would. I was hoping for a way to do this with multiple adruinos 6 to be exact. I'm making a wireless lighting system for a canopy tour that i work at. this is so people can be lit up as they zipline through the night.
joeyballard:
Yes, this is exactly what I meant, if it's not too much trouble to make something like this it would save me a lot of time. I'm not quite advanced enough to make it myself or I would. I was hoping for a way to do this with multiple adruinos 6 to be exact. I'm making a wireless lighting system for a canopy tour that i work at. this is so people can be lit up as they zipline through the night.
Sure, this could work for as many Arduinos as you like, as long as you were willing to keep them all powered up the whole time. It's certainly possible to do this. To keep multiple Arduinos in sync, I would then right it on top of RF24Network which already knows how to communicate between lots of Arduinos behind the scenes. I'll PM you for more details.