-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.js
88 lines (68 loc) · 2.35 KB
/
app.js
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'use strict';
/*
Below is some information about which pins control which servos (aka joints).
Note that the Arduino board is a Due,
Courtesy of anykeynl (http://forum.7bot.cc/read.php?1,6,6#msg-6).
Axis 1; Readout = A0 ; ServoControl D2
Axis 2; Readout = A1 ; ServoControl D3
Axis 3; Readout = A2 ; ServoControl D4
Axis 4; Readout = A3 ; ServoControl D5
Axis 5; Readout = A4 ; ServoControl D6
Axis 6; Readout = A5 ; ServoControl D7
Axis 7; Readout = A6 ; ServoControl D8
Pomp Valve; Control D10 ; Low means open (suction); High closed (no suction)
Pomp motor; Control D11 ; High is on; Low is off
Beep; Control D12 ; High is very irritating noise, Low is peace
Left Button; Readout D71
Right Button; Readout D70
*/
var fs = require('fs');
var config = JSON.parse(fs.readFileSync('config.json', 'utf8'));
var Cylon = require('cylon');
Cylon.robot({
name: '7bot',
connections: {
arduino: { adaptor: 'firmata', port: config.port }
},
devices: {
joint0: { driver: 'servo', pin: 2 },
joint1: { driver: 'servo', pin: 3 },
joint2: { driver: 'servo', pin: 4 },
joint3: { driver: 'servo', pin: 5 },
joint4: { driver: 'servo', pin: 6 },
joint5: { driver: 'servo', pin: 7 },
joint6: { driver: 'servo', pin: 8 },
jointsensor0: { driver: 'analogSensor', pin: 0, lowerLimit: 100, upperLimit: 900 },
jointsensor1: { driver: 'analogSensor', pin: 1, lowerLimit: 100, upperLimit: 900 },
jointsensor2: { driver: 'analogSensor', pin: 2, lowerLimit: 100, upperLimit: 900 },
jointsensor3: { driver: 'analogSensor', pin: 3, lowerLimit: 100, upperLimit: 900 },
jointsensor4: { driver: 'analogSensor', pin: 4, lowerLimit: 100, upperLimit: 900 },
jointsensor5: { driver: 'analogSensor', pin: 5, lowerLimit: 100, upperLimit: 900 },
pumpvalve: { driver: 'led', pin: 10 },
pumpmotor: { driver: 'led', pin: 11 },
},
work: function() {
// interact with robot via socket API from the browser
// See: frontend/app/src/x-app.html
},
commands: function() {
return {
turn_pump_on: this.turnPumpOn,
turn_pump_off: this.turnPumpOff,
};
},
turnPumpOn: function() {
this.pumpmotor.turnOn();
this.pumpvalve.turnOff();
},
turnPumpOff: function() {
this.pumpmotor.turnOff();
this.pumpvalve.turnOn();
},
});
Cylon.api('socketio',
{
host: '0.0.0.0',
port: '3000'
});
Cylon.start();