Some Sparkis come with a radio module. It allows Sparkis to communicate wirelessly with other Sparkis that also have radio modules. It can not currently be used to communicate with a computer. These modules come pre-included with the MAKE edition Sparkis, or can be purchases separately in our store.
With the radio plugged into two or more Sparkis, you can use it to send different variables to other Sparkis. The following examples are for two different Sparkis. One is sending char variables, and the other is receiving them. The example below comes with the latest version of SparkiDuino:
Transmitting Sparki
Receiving Sparki
This example sends
char data. You can also different write/read commands for ints and floats:
Using the Part
The radio module is inserted into Sparki’s expansion port pins:With the radio plugged into two or more Sparkis, you can use it to send different variables to other Sparkis. The following examples are for two different Sparkis. One is sending char variables, and the other is receiving them. The example below comes with the latest version of SparkiDuino:
Transmitting Sparki
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
#include <SPI.h> #include <Radio.h> Radio radio; void setup() { radio.begin(); } char start[] = "Hello"; void loop() { for(int i=0; i<5; i++){ radio.writeChar(start[i]); } delay(1000); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
/******************************************* Basic Radio test Some versions of Sparki come with an NRF24L01+ radio module. This code will let you test the module on a Sparki, using the serial monitor. http://arcbotics.com/products/sparki/parts/radio/ ********************************************/ #include <SPI.h> #include <Radio.h> Radio radio; void setup() { Serial.begin(9600); radio.begin(); } char start[] = "Hello"; void loop() { // Uncomment this code if receiving if ( radio.available() ){ // if data is unread from the radio Serial.println( radio.readChar() ); } } |
1 2 3 4 5 6 7 |
radio.writeChar(char) radio.writeInt(int) radio.writeFloat(float) radio.readChar() radio.readInt() radio.readFloat() |