Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Arduino Wireless Communication Tutorial
- * Example 1 - Transmitter Code
- *
- * by Dejan Nedelkovski, www.HowToMechatronics.com
- *
- * Library: TMRh20/RF24, https://github.com/tmrh20/RF24/
- */
- #include <SPI.h>
- #include <nRF24L01.h>
- #include <RF24.h>
- RF24 radio(7, 8); // CE, CSN
- const byte addresses[][6] = {"00001", "00002"};
- int i = 0;
- void setup() {
- radio.begin();
- radio.openWritingPipe(addresses[1]);
- radio.openReadingPipe(1, addresses[0]);
- radio.setPALevel(RF24_PA_MIN);
- Serial.begin(9600);
- }
- /*
- void loop() {
- radio.startListening();
- if(radio.available()) {
- while(radio.available()) {
- char text[32] = "";
- radio.read(&text, sizeof(text));
- Serial.println(text):
- }
- radio.stopListening();
- String besedilo = "Lorem.";
- char dajbek[32];
- besedilo.toCharArray(dajbek, 32);
- radio.write(&dajbek, sizeof(dajbek));
- }
- }
- */
- void loop() {
- char text[32];
- String besedilo = "Lorem ipsum";
- radio.stopListening();
- // besedilo.concat(i);
- // Serial.println(besedilo);
- besedilo.toCharArray(text, 32);
- radio.write(&text, sizeof(text));
- // memset(text, 0, sizeof(text));
- delay(5);
- radio.startListening();
- while (!radio.available());
- Serial.println("Zabase se");
- char preberi[32];
- radio.read(&preberi, sizeof(preberi));
- Serial.println(preberi);
- memset(preberi, 0, sizeof(preberi));
- i++;
- Serial.println(i);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement