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.

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?
    – joan
    Commented Jul 5, 2015 at 17:27
  • I added some more information for you :)
    – TobiasW
    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.

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.

-1

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

3
  • 1
    @Thunder: The original poster is incorrect. Jython is a python implementation written in Java. Java and javascript are not related.
    – Jacobm001
    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 :)
    – TobiasW
    Commented Jul 7, 2015 at 19:18
  • Jython is short for Java-Python, not Javascript related at all
    – Erik
    Commented Nov 5, 2016 at 23:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.