/* This is a simple test program to test if the stepper motor driver is working. * Adjust the pins numbers to the driver you are testing: * set 1: dirPin A1, stepPin A2, enablePin A3 * set 2: dirPin 13, stepPin 12, enablePin A0 * For the A4988 short circuit the Sleep pin to the next one with a jumper. For the TMC2208 this is not needed. * For the A4988 use two jumpers for microstepping. For the TMC2208 this is not needed. * The A4988 has the enable pin set to low in order to make the stepper turn. */ #define dirPin A1 #define stepPin A2 #define enablePin A3 const int stepTime = 500; int i; void setup() { Serial.begin(115200); pinMode(stepPin,OUTPUT); pinMode(dirPin,OUTPUT); pinMode(enablePin,OUTPUT); digitalWrite(enablePin, LOW); } //end void setup void loop() { for(i=0; i<1000; i++) { turn(0); } delay(1000); for(i=0; i<1000; i++) { turn(1); } delay(1000); } //end void loop void turn(int direction) { digitalWrite(dirPin, HIGH); digitalWrite(stepPin, HIGH); delayMicroseconds(stepTime); digitalWrite(stepPin, LOW); delayMicroseconds(stepTime); } //end void turn
/*This is code to test the possibilities of a 16x2 character LCD screen with a I2C saddle. * Connect SDA to pin A4 and SDC to pin A5 */ #include <Wire.h> #include <LiquidCrystal_I2C.h> //constants for the number of rows and columns in the LCD const int numRows= 2; const int numCols= 16; //initialize the library with the numbers of the interface pins LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); void setup(){ lcd.begin(numCols, numRows); lcd.clear(); lcd.setCursor(0,0); //set the cursor to the first line to display "Hello...." lcd.print("Hello there!!!"); delay(1000); } void loop(){ //displays the number of seconds which has elapsed since code is uploaded lcd.setCursor(0,0); //set the cursor to column 0, line 2 lcd.print("1234567890123456 "); delay(1000); lcd.setCursor(0,2); lcd.print(millis()/1000); //displays the number of seconds which has elapsed since code is uploaded lcd.print(" sec elapsed"); }
/* This is code to test the basic Up/Down/CW/CCW switches on the control box. * Open the serial console to check for output. */ //Globals #define switchCCW 3 #define switchCW 4 #define switchUp 5 #define switchDwn 6 int swCCW,swCW,swUp,swDwn; void setup() { Serial.begin(115200); } void loop() { swCCW = digitalRead(switchCCW); swCW = digitalRead(switchCW); swUp = digitalRead(switchUp); swDwn = digitalRead(switchDwn); if (swCCW == 1){ Serial.println("Counterclockwise"); } if (swCW == 1){ Serial.println("Clockwise"); } if (swUp == 1){ Serial.println("Up"); } if (swDwn == 1){ Serial.println("Down"); } }
/* This is a simple test program to test if the stepper motor driver is working with buttons. * Adjust the pins numbers to the driver you are testing: * set 1: dirPin A1, stepPin A2, enablePin A3 * set 2: dirPin 13, stepPin 12, enablePin A0 * For the A4988 short circuit the Sleep pin to the next one with a jumper. For the TMC2208 this is not needed. * For the A4988 use two jumpers for microstepping. For the TMC2208 this is not needed. * The A4988 has the enable pin set to low. */ //Globals #define dirPin A1 #define stepPin A2 #define enablePin A3 #define switchCCW 3 #define switchCW 4 const int stepTime = 500; int swCCW,swCW; void setup() { pinMode(stepPin,OUTPUT); pinMode(dirPin,OUTPUT); pinMode(enablePin,OUTPUT); digitalWrite(enablePin,HIGH); } void loop() { swCCW = digitalRead(switchCCW); swCW = digitalRead(switchCW); if(swCCW == HIGH) { digitalWrite(enablePin,LOW); turn(1); } if(swCW == HIGH) { digitalWrite(enablePin,LOW); turn(0); } else{ digitalWrite(enablePin, HIGH); } } //end loop() void turn(int direction) { digitalWrite(dirPin,direction); digitalWrite(stepPin,HIGH); delayMicroseconds(stepTime); digitalWrite(stepPin,LOW); }
Page 1: Materials used
Page 2: Photos and Videos
Page 3: Arduino Code