Thank you.
I think one of these bad boys should do the trick.
Thank you.
I think one of these bad boys should do the trick.
I'm using a omega 2 Arduino dock 2 and have it connected to a easydriver to run a stepper motor. I'm trying to remotely turn a stepper motor. The omega has a python server that is waiting for http requests. This is the python code.
--
import onionGpio
from flask import Flask, request
app = Flask(name)
gpioLeft = 4
gpioMiddle = 2
gpioRight = 3
gpioObjLeft = onionGpio.OnionGpio(gpioLeft)
gpioObjMiddle = onionGpio.OnionGpio(gpioMiddle)
gpioObjRight = onionGpio.OnionGpio(gpioRight)
status = gpioObjLeft.setOutputDirection(0)
@app.route('/',methods=['POST'])
def gpio():
if request.form['blind'] == 1:
status = gpioObjLeft.setValue(1)
elif request.form['blind'] == 2:
status = gpioObjMiddle.setValue(1)
else:
status = gpioObjRight.setValue(1)
print 'GPIO%d set to: %d'%(gpioNum, value)
time.sleep(10)
status = gpioObjLeft.setValue(0)
return 'success'
if name == "main":
app.run(host='0.0.0.0')
--
Then on the arduino I have the following code:
--
#define DIR_PIN 2
#define STEP_PIN 3
#define INPUT_PIN 4
void setup() {
pinMode(DIR_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
pinMode(INPUT_PIN, INPUT);
Serial.begin(9600);
Serial.print("SETUP Value");
}
void loop() {
//rotate a specific number of degrees
if (digitalRead(4) == HIGH){
rotateDeg(3600, 1);
Serial.print("High Value");
delay(4000);
} else {
Serial.print("Low Value");
delay(4000);
}
}
void rotate(int steps, float speed) {
//rotate a specific number of microsteps (8 microsteps per step) – (negitive for reverse movement)
//speed is any number from .01 -> 1 with 1 being fastest – Slower is stronger
int dir = (steps > 0) ? HIGH : LOW;
steps = abs(steps);
digitalWrite(DIR_PIN, dir);
float usDelay = (1 / speed) * 70;
for (int i = 0; i < steps; i++) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(usDelay);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(usDelay);
}
}
--
The problem is the stepper motor is running constantly. So it seem that that green wire listed below (Pin 3) is always giving a high value. Does anyone know what I'm doing wrong? I'm very much a software guy not hardware.
I currently have the Omega2 powered by a microUSB to an outlit.
The easydriver has its own power supply.