O'Reilly logo

Programming the BeagleBone by Yogesh Chavan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Controlling a servo motor through LAN

We controlled an LED remotely. The same program can be extended to control a micro servo motor. But buttons inside the webpage cannot give real control on an analog motor. So, we will use a slider/range input to control the micro servo motor.

HTML code

Open Cloud9 IDE and create a new file named servo.html. Write the following code in servo.html.

The code for servo.html is as follows:

<!DOCTYPE html> <html> <head> <script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect(); function pwm(value){ socket.emit('pwm',value); } </script> </head> <body> <div> <label for="servo">Servo:</label> <input type="range" name="servo" id="servo" value="50" min="0" max="180" onChange="pwm(value);"> </div> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required