-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.js
More file actions
48 lines (40 loc) · 1.2 KB
/
controller.js
File metadata and controls
48 lines (40 loc) · 1.2 KB
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
var RaspiRobot = require("raspirobot").RaspiRobot;
function Controller(config){
if (typeof config.mockBot !== 'undefined' && process.argv[2] == 'mock'){
this.robot = config.mockBot;
}else{
this.robot = new RaspiRobot();
}
this.robot.setup();
}
module.exports = Controller;
Controller.prototype.forward = function(){
this.robot.setMotor('left', 1, 1);
this.robot.setMotor('right', 1, 1);
};
Controller.prototype.back = function(){
this.robot.setMotor('left', 1, 0);
this.robot.setMotor('right', 1, 0);
};
Controller.prototype.wideLeft = function() {
this.robot.setMotor('left', 0, 0);
this.robot.setMotor('right', 1, 1);
};
Controller.prototype.wideRight = function() {
this.robot.setMotor('left', 1, 1);
this.robot.setMotor('right', 0, 0);
};
Controller.prototype.left = function(){
this.robot.setMotor('left', 1, 0);
this.robot.setMotor('right', 1, 1);
};
Controller.prototype.right = function(){
this.robot.setMotor('left', 1, 1);
this.robot.setMotor('right', 1, 0);
};
Controller.prototype.stop = function(){
this.robot.setMotor('left', 0, 0);
this.robot.setMotor('right', 0, 0);
};
Controller.prototype.beep = function(){
};