Hello,
I am relatively new to arduino and processing. I have a 4-wire bipolar stepper motor which I can control with arduino UNO + the arduino motor shield using the following (standard example) code in the arduino IDE:
#include <Stepper.h>
const int spr = 20; // motor steps per revolution
const int pwm_cha = 3;
const int pwm_chb = 11;
const int dir_cha = 12;
const int dir_chb = 13;
const int brake_cha = 9;
const int brake_chb = 8;
Stepper stepper(spr, dir_cha, dir_chb);
void setup()
{
pinMode(pwm_cha, OUTPUT);
pinMode(pwm_chb, OUTPUT);
pinMode(brake_cha, OUTPUT);
pinMode(brake_chb, OUTPUT);
digitalWrite(pwm_cha, HIGH);
digitalWrite(pwm_chb, HIGH);
digitalWrite(brake_cha, LOW);
digitalWrite(brake_chb, LOW);
stepper.setSpeed(50);
}
void loop()
{
stepper.step(spr);
delay(2000);
}
The code basically just turns a 20-step (or any other “_”-step) motor for one complete revolution, then pauses for two seconds, and turns for another revolution etc.
My question is this: How do I do just this exact thing using Processing?
(It’s a rather elementary sort of task but I’ve been completely unable to find it anywhere on the arduino or processing fora or reference or anywhere else at all.)
Is there a simple way to port the arduino code from arduino IDE to processing? Can I use the arduino stepper motor libraries in conjunction with processing, or does processing have its own such libraries?
I need to control some other sensors and data analysis in processing based on inputs which vary with the position of the motor, which I only need to sweep through a prespecified number of steps on each run of the program (I don’t need any motor control commands from the keyboard or anything like that). I wanted to streamline the whole motor-control/sensory input/data aquisition into one easy processing sketch.
Any suggestions?
Thanks!