Hi,
I've been fiddling with an Arduino UNO- and have had some unexpected issues I have yet to resolve. I was hoping to get a few ideas of things to look into.
First- I am powering the UNO (which is several years old) via USB from a laptop. I am powering the stepper board with a "wall wart" 3-12v 750ma ps- on 12v.
The first issue I have found, is using a small stepper motor (this-- https://www.allelectronics.com/item/me-125/stepper-motor-and-driver-board/1.html )
when I use only code to step the motor (in loop-- step-, delay, step+, delay, nothing else,) it works great. When I use the extra code (shown below) that adds a do-while loop and a change in stepper position after a condition is met, the stepper loses steps/ doesn't seem to go to the - step positions/ etc.
Could this be because of USB power issues? I do have other boards, UNO's, a redboard, a couple nano clones to try that I haven't done yet.
Any ideas?-- Thanks in advance!
#include <Adafruit_GFX.h>
#include <ArducamSSD1306.h>
#include <Wire.h>
#include <SPI.h>
#define OLED_RESET 16
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
ArducamSSD1306 display(OLED_RESET);
const int button_1 = 8;
int sensorPin = A0;
int sensorValue = 0;
int var = 0;
int cycle_delay = 100;
#include <Stepper.h>
#define STEPS 32
Stepper stepper(STEPS, 8, 10, 9, 11);
void setup(){
stepper.setSpeed(600);
}
void loop(){
do{
stepper.step(-110);
delay(800);
stepper.step(110);
delay(800);
var++;
cycle_delay=analogRead(0);
cycle_delay=map(cycle_delay,0,1023,30,600);
}
while (var<cycle_delay);
delay(800);
stepper.step(110);
delay(800);
stepper.step(-110);
delay(800);
stepper.step(110);
delay(800);
stepper.step(-110);
delay(800);
var=0;
}