Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <nRF24L01.h>
- #include <RF24.h>
- #include <Wire.h>
- int distance;
- RF24 radio(7, 8);
- const uint64_t pipes[3] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0E2LL, 0xF0F0F0F0E3LL };
- void setup(void) {
- // put your setup code here, to run once:
- Serial.begin(9600);
- radio.begin();
- radio.setDataRate(RF24_250KBPS);
- radio.openReadingPipe(1, pipes[1]);
- //radio.openReadingPipe(2, pipes[2]);
- radio.startListening();
- }
- void loop(void) {
- // put your main code here, to run repeatedly:
- if ( radio.available() )
- {
- float distance; // Fetch the data payload
- //radio.read(&distance,sizeof(distance));
- memset(&distance,' ',sizeof(distance));
- radio.read(&distance,sizeof(distance));
- Serial.print("X = ");
- Serial.println(distance);
- // Serial.println(distance);
- delay(500);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement