davidrs / johnny-five-intro

flashing led and web controls over server
0 stars 0 forks source link

servo #1

Open thenetw0rk opened 10 years ago

thenetw0rk commented 10 years ago

hi

i see in the coding the servo part is there

how to i add it to the index.html so it turns the servo

davidrs commented 10 years ago
  1. you would need to create a route in the server.js something like:
app.get('/servo/:angle', function(req, res){
    console.log('received cmd ', req.params.angle);
    if(hardware.servo){
        hardware.servo.to(req.params.angle);
    }
  res.send('led *');
});
  1. Then in index.html create a text box or slider that takes it's value and sends it to
localhost:3000/servo/(whatever angle you want)
localhost:3000/servo/45

You could also just do step 2, and use the existing patrick/wave/ url

thenetw0rk commented 10 years ago

thanks for coming back, i worked it out using the existing patrick/wave/ url but only sweeping

im going try and put a text box like you suggested