Newer
Older
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
52
53
54
55
56
57
58
59
#include <Servo.h>
#include <WallVis.h>
WallVis node(
"new001", // Our ID
"WallVisNet", //Wifi Access Point
"wallvisAP", //WiFi Password
"192.168.4.1",//IP address of Node RED server
1883 //Port for Node RED server
);
// Set up the servo we will use
Servo s1 = Servo();
Servo s2 = Servo();
Servo s3 = Servo();
Servo s4 = Servo();
void setup()
{
// Attach the servo to the right pin on the board
s1.attach(D1);
s2.attach(D2);
s3.attach(D3);
s4.attach(D4);
s1.write(0);
s2.write(0);
s3.write(0);
s4.write(0);
//Get the serial port ready
Serial.begin(115200);
//Add in a behaviour that just goes to a certain angle, with the default name 'goto'
node.add(new ServoGoto(s1,"goto1") );
node.add(new ServoGoto(s2,"goto2") );
node.add(new ServoGoto(s3,"goto3") );
node.add(new ServoGoto(s4,"goto4") );
//Add in a behaviour that rotates from 0 to 180 and back again (e.g. dropping a ball trustball style)
node.add(new RotateReturn(s1,"drop1",1,500, 3, 175) );
node.add(new RotateReturn(s2,"drop2",1,500, 3, 175) );
node.add(new RotateReturn(s3,"drop3",1,500, 3, 175) );
node.add(new RotateReturn(s4,"drop4",1,500, 3, 175) );
//Initialise the whole infrastructure
node.set_wifi(false);
node.init();
}
void loop()
{
//Should be all we have to do
node.vis_loop();
}