Skip to content

Instantly share code, notes, and snippets.

@michael34435
Forked from anonymous/gist:32672c538e020c705f25
Last active March 1, 2016 14:39
Show Gist options
  • Save michael34435/642566724137c41e538a to your computer and use it in GitHub Desktop.
Save michael34435/642566724137c41e538a to your computer and use it in GitHub Desktop.
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