-
Notifications
You must be signed in to change notification settings - Fork 0
/
emitter.ino
40 lines (29 loc) · 1.1 KB
/
emitter.ino
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
#include <SPI.h>
#include<RF24.h>
RF24 radio (7, 8);
struct package //struct of data to be sent
{
int valbx = 90;
int valby = 90;
}data;
byte addresses[][6] = {"0"}; //addresses
int valx; //initializes values of horizontal and vertical servos
int valy;
void setup()
{
//radio setup
radio.begin();
radio.setChannel(115);
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate( RF24_250KBPS ) ;
radio.openWritingPipe(addresses[0]);
//end of radio setup
}
void loop()
{
valx = analogRead(0); //potentiometer attached to A0 pin
valy = analogRead(1); //potentiometer attached to A1 pin
valx = map(valx,0,1023,0,179); //mapping to the right values
valy = map(valy,0,1023,0,179);
radio.write(&data,sizeof(data)); //sending data
}