Limit Switches for Drawbot

I was able to get this working roughly.

I made some beads put onto the strings. These beads will trigger my limit switches.

I then wrote a small program to go through the calibration process twice then move the system to (0,0 Cartesian).

It works pretty consistently. I know I’ll change it as the bot will probably finish at the top right. So I need to make sure it can do a zero operation from there and also from 0,0.

I suppose I could have a switch. If the switch is on, then the system will do a calibration run on boot-up.

The code is at the bottom.

/* Darcy Whyte, DrawBot2 */

// limit switch
const int switchHome = 7;     // home switch
const int ledHome =  8;      // home LED

//Motor S
const int motorAStep = 0;
const int motorADir = 1;
const int motorBStep = 2;
const int motorBDir = 3;

int i; int j;
int switchHomeState = 0;         
int homeA = 0;
int homeB = 0;

void setup() {
  pinMode(ledHome, OUTPUT);      
  pinMode(switchHome, INPUT);     
  pinMode(motorAStep, OUTPUT);
  pinMode(motorADir, OUTPUT);
  pinMode(motorBStep, OUTPUT);
  pinMode(motorBDir, OUTPUT);

  //seek home
  //switchHomeState == LOW; //don't start till switch
  //digitalWrite(ledHome, LOW);
  //while (switchHomeState == LOW) {
  //  switchHomeState = digitalRead(switchHome);
  //  if (switchHomeState == HIGH) {    
  //    digitalWrite(ledHome, HIGH);  
  //  }
  //while (switchHomeState == HIGH) {  //wait switch release
  //  switchHomeState = digitalRead(switchHome);
  //  if (switchHomeState == LOW) {    
  //    digitalWrite(ledHome, LOW);  
  //  }

  for (j=1; j


One thought on “Limit Switches for Drawbot

Comments are closed.