0

I'm new to Python and Raspberry Pi. I'm trying to drive a stepper motor with the Rpi from this website: http://www.sundh.com/blog/2014/02/control-stepper-motors-with-raspberry-pi-and-node-js/

I find an error for my gpio variable in python. It says "Syntax Error: Invalid Syntax". Would really appreciate any help.

The error is on the first line. 'gpio' was highlighted in RED. IDLE 3 says syntax error.

Below is my code:

var gpio=require("pi-gpio");
stopMotors = false;
function sleep(milliseconds) {
 var start = new Date().getTime();
 for (var i = 0; i < 1e7; i++) {
 if ((new Date().getTime() - start) > milliseconds){
 break;
 }
 }
}
gpio.open(16,"output",function(err){ 
 console.log("Pin 16 open"); // Opens pin 16 as output 
});
gpio.open(18,"output",function(err){ 
 console.log("Pin 18 open"); // Opens pin 18 as output 
});
// Runs motor in the set direction
function move() {
 gpio.write(16, 1, function() { 
 sleep(1000); 
 gpio.write(16, 0, function() { 
 sleep(1000); 
 if(!stopMotors)move(); 
 }); 
 }); 
}
function stopMotor() {
 stopMotors = true;
}
// Changing direction of motor
function left() {
 stopMotors = false;
 gpio.write(18, 1, function() { 
 move();
 }); 
}
// Changing direction of motor
function right() {
 stopMotors = false;
 gpio.write(18, 0, function() { 
 move();
 }); 
}

BTW is this even python? Im entering these in IDLE3.

Can you help me please?

asked Oct 28, 2014 at 10:54

1 Answer 1

1

I would assume it's JavaScript as node.js is " an open source, cross-platform runtime environment for server-side and networking applications. Node.js applications are written in JavaScript, and can be run within the Node.js runtime on OS X, Microsoft Windows, Linux and FreeBSD."

answered Oct 28, 2014 at 11:03

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.