-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrx.cpp
More file actions
51 lines (38 loc) · 767 Bytes
/
Copy pathrx.cpp
File metadata and controls
51 lines (38 loc) · 767 Bytes
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// SimpleRx - the slave or the receiver
#include <Arduino.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
const byte thisSlaveAddress[5] = {'R', 'x', 'A', 'A', 'A'};
RF24 radio(CE_PIN, CSN_PIN);
uint8_t ledPin = A1;
uint8_t buttonState;
//===========
void getData();
void setup()
{
digitalWrite(ledPin,HIGH);
pinMode(ledPin, OUTPUT);
radio.begin();
radio.setDataRate(RF24_250KBPS);
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
void loop()
{
getData();
}
//==============
void getData()
{
if (radio.available())
{
radio.read(&buttonState, sizeof(buttonState));
digitalWrite(ledPin,LOW);
delay(500);
digitalWrite(ledPin,HIGH);
}
}