Help with Conversion From Arduino C to Propeller1 Spin
AwesomeCronk
Posts: 1,055
Hello, I am making progress with the issue described here.
I found some code to use these things with an Arduino, alongside pin definitions, and pinout diagrams. Can anyone here who uses the Prop1 and has Arduino experience please help me decipher this code?
I found some code to use these things with an Arduino, alongside pin definitions, and pinout diagrams. Can anyone here who uses the Prop1 and has Arduino experience please help me decipher this code?
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
void setup()
{
radio.begin();
radio.setRetries(15, 15);
radio.openWritingPipe(rxAddr);
radio.stopListening();
}
void loop()
{
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
delay(1000);
}
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8);
const byte rxAddr[6] = "00001";
void setup()
{
while (!Serial);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, rxAddr);
radio.startListening();
}
void loop()
{
if (radio.available())
{
char text[32] = {0};
radio.read(&text, sizeof(text));
Serial.println(text);
}
}
First chunk is transmitter, second chunk is receiver. 
Comments
******************************************************************************************* #include <SPI.h> #include <nRF24L01.h> #include <RF24.h> These includes would need to be replaced with equivalent objects or code RF24 radio(7, 8); '*********** probably send/receive pins on arduino ******************************************************************************************* const byte rxAddr[6] = "00001"; *********** setting data in an array location ??? (purpose unknown at present) void setup() { radio.begin(); ********** startup for the RF24 module radio.setRetries(15, 15); ********** number of retries for send & receive ??? radio.openWritingPipe(rxAddr); ********** set RF24 to transmit data ??? radio.stopListening(); ********** Turn receiver off/transmit on ??? } void loop() ********** send "Hello World" once a second { const char text[] = "Hello World"; radio.write(&text, sizeof(text)); delay(1000); } ******************************************************************************************* #include <SPI.h> #include <nRF24L01.h> #include <RF24.h> RF24 radio(7, 8); Same as sending above ******************************************************************************************* const byte rxAddr[6] = "00001"; *********** setting data in an array location ??? (purpose unknown at present) void setup() { while (!Serial); Serial.begin(9600); *********** setting up the serial port radio.begin(); *********** starting up the radio radio.openReadingPipe(0, rxAddr); ************ open up the read function ??? radio.startListening(); *********** start listening for data } void loop() { if (radio.available()) { char text[32] = {0}; ************ clear the receive buffer radio.read(&text, sizeof(text)); ************ put received data into the "text" array Serial.println(text); ************ print the data ( i'm assuming this is similar to printing to the P1 debug terminal ) } }There are most likely objects in the OBEX to perform similar functions to the SPI.h, nRF24L01.h, and RF24.h code. Looking at the library code will also help.
I was using the text editor that comes with Linux Mint to paste the code you posted and add the comments so notepad should work.