2

So I have seen some examples, how you can control servo-motors with javascript, but we use 2 stepper-motors for our project and these use an extra library in python. So is there a way to control them with javascript or to control a python script with javascript?

More information:

I want a mobile website or hybrid app to control these 2 stepper motors, just simple sliders to give them some speed and stop them. So the Web-Interface should communicate with WebSocket to my raspi. The WebSocket should be Socket.io with NodeJS. We use the Adafruit stepper-motor control-board, which has it's own library to control them.

asked Jul 5, 2015 at 14:41
2
  • 1
    JavaScript is a general purpose language so will be able to talk to a library to control gpios. I suspect you want to run the JavaScript in a web browser which brings unique problems. Could you explain what you are trying to do? Commented Jul 5, 2015 at 17:27
  • I added some more information for you :) Commented Jul 6, 2015 at 8:25

3 Answers 3

1

From your first paragraph, yes, it's possible to call python from NodeJS, check out ChildProcess. Using that facility you can then communicate directly with the Python program that actually controls the motors.

answered Jul 9, 2015 at 17:04
1

Try nodejs on your RPi, and then use subprocess module of python to controlled javascript routines , I would also like you to check johnny-five lib of nodejs.

answered Jul 5, 2015 at 17:00
-1

Take a look at jython It is a python in javascript.

answered Jul 5, 2015 at 16:12
3
  • 1
    @Thunder: The original poster is incorrect. Jython is a python implementation written in Java. Java and javascript are not related. Commented Jul 6, 2015 at 16:21
  • Oh, ok thanks I had no time yet to check that out, but thanks that saves me some time :) Commented Jul 7, 2015 at 19:18
  • Jython is short for Java-Python, not Javascript related at all Commented Nov 5, 2016 at 23:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.