Skip to content

Commit

Permalink
Added package.json to simplify the npm install steps.
Browse files Browse the repository at this point in the history
Using GPIO23 as an enable for the motor driver module
  • Loading branch information
jasonrock21 committed Feb 26, 2018
1 parent 11c8162 commit 55c4684
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ZeroBot Custom
Leveraging the ZeroBot - Raspberry Pi Zero FPV Robot project: https://hackaday.io/project/25092-zerobot-raspberry-pi-zero-fpv-robot

Modifications
* Added a package.json to incorporate the package dependencies
* Using Raspberry Pi's GPIO 23 as an enable pin for the motor driver module
28 changes: 16 additions & 12 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ var Gpio = require('pigpio').Gpio,
A1 = new Gpio(27, {mode: Gpio.OUTPUT}),
A2 = new Gpio(17, {mode: Gpio.OUTPUT}),
B1 = new Gpio( 4, {mode: Gpio.OUTPUT}),
B2 = new Gpio(18, {mode: Gpio.OUTPUT});
LED = new Gpio(22, {mode: Gpio.OUTPUT});
B2 = new Gpio(18, {mode: Gpio.OUTPUT}),
LED = new Gpio(22, {mode: Gpio.OUTPUT}),
MOTOR_en = new Gpio(23, {mode: Gpio.OUTPUT});

// Enable the motors
MOTOR_en.digitalWrite(1);

app.get('/', function(req, res){
res.sendfile('Touch.html');
Expand All @@ -23,11 +27,11 @@ child = exec("sudo bash start_stream.sh", function(error, stdout, stderr){});
//Whenever someone connects this gets executed
io.on('connection', function(socket){
console.log('A user connected');

socket.on('pos', function (msx, msy) {
//console.log('X:' + msx + ' Y: ' + msy);
//io.emit('posBack', msx, msy);

msx = Math.min(Math.max(parseInt(msx), -255), 255);
msy = Math.min(Math.max(parseInt(msy), -255), 255);

Expand All @@ -49,11 +53,11 @@ io.on('connection', function(socket){


});

socket.on('light', function(toggle) {
LED.digitalWrite(toggle);
});
LED.digitalWrite(toggle);
});

socket.on('cam', function(toggle) {
var numPics = 0;
console.log('Taking a picture..');
Expand All @@ -67,13 +71,13 @@ io.on('connection', function(socket){
io.emit('cam', 1);
});
});

});

socket.on('power', function(toggle) {
child = exec("sudo poweroff");
});

//Whenever someone disconnects this piece of code is executed
socket.on('disconnect', function () {
console.log('A user disconnected');
Expand All @@ -91,7 +95,7 @@ io.on('connection', function(socket){
});
if(!adc.busy){
adc.readADCSingleEnded(0, '4096', '250', function(err, data){ //channel, gain, samples
if(!err){
if(!err){
voltage = 2*parseFloat(data)/1000;
console.log("ADC: ", voltage);
io.emit('volt', voltage);
Expand Down
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "zerobot-custom",
"description": "Based on the 'Raspberry Pi Zero FPV Robot' hackaday project",
"version": "1.0.1",
"homepage": "https://github.com/jasonrock21/ZeroBot.git",
"license": "GPL-3.0",
"main":"app.js",
"repository": {
"type": "git",
"url": "https://github.com/jasonrock21/ZeroBot.git"
},
"scripts": {
"start": "sudo node app.js"
},
"dependencies": {
"express": "^4.16.2",
"socket.io": "^2.0.4",
"pigpio": "^0.7.0"
}
}

0 comments on commit 55c4684

Please sign in to comment.