-
-
Save michael34435/642566724137c41e538a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var m = require('mraa'); //IO Library | |
var express = require('express') | |
var app = express(); | |
var exec = require('sync-exec'); | |
app.use(express.static('static')); | |
var blinkInterval = 1000; //set default blink interval to 1000 milliseconds (1 second) | |
var blinkStatus = false; | |
var ledState = 1; //set default LED state | |
var point_Alpha = 0 ; | |
var myLed = new m.Gpio(17); //LED hooked up to digital pin 13 | |
myLed.dir(m.DIR_OUT); //set the gpio direction to output | |
/////////////////////////////////////////////////// | |
///////// Express Server ////////////////////////// | |
/////////////////////////////////////////////////// | |
app.get('/play.html',function(request, response){ | |
response.sendFile(__dirname + '/play.html'); | |
}); | |
app.get('/intro.html',function(request, response){ | |
response.sendFile(__dirname + '/intro.html'); | |
}); | |
app.get('/',function(request, response){ | |
response.sendFile(__dirname + '/index.html'); | |
}); | |
app.get('/changeBlinkStatus', function(request, response){ | |
blink(); | |
}); | |
app.get('/pointer/:alpha',function(request, response){ | |
var alpha = request.params.alpha; | |
exec('python v_servo.py ' + parseFloat(alpha / 400)); | |
}); | |
function blink(){ | |
blinkStatus = !blinkStatus; | |
// ledState = !ledState; | |
myLed.write(blinkStatus ? 1 : 0); //write the LED state | |
// ledState = 1 - ledState; //toggle LED state | |
// setTimeout(blink,blinkInterval); //recursively toggle pin state with timeout set to blink interval | |
} | |
function servo(){ | |
} | |
app.listen(8080, '0.0.0.0',function(){ | |
console.log('HTTP............ http://127.0.0.1:8080/ .........'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment