im not the greatest at writing code or that fluent with arduino (yet, im trying to learn), ive written a quick code to control the speed of two stepper motors, one as a filament puller and one to drive a spool to collect filament as it is pulled, the hopes are to have this eventually controlled by a digital caliper to measure the diameter of the filament.
until i become more competent with writing working sketches id basically planned to control these steppers with 10k pots, using this code.
int steppin = 5;
int dirpin = 8;
int stepdelay;
int steppin1 = 6;
int dirpin1 = 9;
int stepdelay1;
void setup() {
pinMode (steppin, OUTPUT);
pinMode (dirpin, OUTPUT);
digitalWrite (dirpin, HIGH); //change this to change direction.
pinMode (steppin1, OUTPUT);
pinMode (dirpin1, OUTPUT);
digitalWrite (dirpin1, HIGH); //change this to change direction.
}
void loop() {
int val = analogRead(A7);
stepdelay = map(val, 0, 1023, 1, 1000);
digitalWrite(steppin, HIGH);
delayMicroseconds (stepdelay);
digitalWrite(steppin, LOW);
delayMicroseconds(stepdelay);
int val1 = analogRead(A6);
stepdelay1 = map(val1, 0, 1023, 1, 1000);
digitalWrite(steppin1, HIGH);
delayMicroseconds (stepdelay1);
digitalWrite(steppin1, LOW);
delayMicroseconds(stepdelay1);
}
unfortunately it doesnt work.
im using one of these CNC Shield V4 Expansion Board Nano 3.0 Stepper A4988 Driver for Arduino 3d PR LP for sale online | eBay
ive mapped the pins so the connections are correct, the only time ive had a motor turning is when i picked it up to check it and touched something on the board.
any help would be much appreciated and if i need to supply any more information please let me know