You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have included notes in the following code describing what I am trying to accomplish and some of the many attempts I've made to come up with logic to make it work. I'm not sophisticated at programming, though I have made a variety of successful projects with non-Arduino systems. For some (probably obvious) reason, this one eludes me.
/* There are 12 magnets on a rotational perimeter with a hall effect sensor used to determine when one has arrived. * The desire is to pass up 11 magnets and stop at the 12th. I can get the system to respond and stop * at every sensor with the While routine below. The accompanying If routine will not respond when a * magnet passes. The other two routines simply stop at eveRy magnet. * The system uses a Teensy 3.5 and a TB67S279FTG driver.*/
#include"Arduino.h"
#include"TeensyStep.h"
Stepper motor(19,18); // STEP pin: 19, DIR pin: 18
RotateControl controller; // use for indefinite movesconst byte ENABLE = 14; // to enable the driver (or save current drain)const byte EXPOSURE = 8; // button to initiate exposure const byte HOUR_PIN = 4; // hour magnets interacting with sensor
byte hour_count = 0; // last known hour count : for tracking exposure progressvoidsetup() {
pinMode(ENABLE, OUTPUT); // ENABLE is output pindigitalWrite(ENABLE, HIGH); // disable driverpinMode(EXPOSURE, INPUT_PULLUP); // exposure switchpinMode(HOUR_PIN, INPUT_PULLUP); // sensor magnet locations
motor
.setMaxSpeed(10000) // steps/s
.setAcceleration(50000); // steps/s^2
}
voidexposure() {
hour_count= 0; // reset hour_countdigitalWrite(ENABLE, LOW); // enable driver
controller.rotateAsync(motor);
/* THIS DOES NOT RESPOND TO THE MAGNETS if (digitalRead(HOUR_PIN) == LOW){ controller.stop(); // stop motor and return immediately }*//* THIS WILL RESPOND TO EACH MAGNET AND STOP AT EACH IN TURN while (digitalRead(HOUR_PIN) == HIGH){} // wait until magnet is sensed controller.stop(); delay(5000);*//* THIS STOPS AT EVERY MAGNET while (hour_count < 12){ if (digitalRead(HOUR_PIN) == LOW){ hour_count = hour_count + 1; } } controller.stop(); // stop motor and return immediately}*//* THIS STOPS AT EVERY MAGNET while (hour_count < 12){ if (digitalRead(HOUR_PIN) == LOW){ hour_count = hour_count + 1; } } controller.stop(); // stop motor}*/voidloop() { // look for button actuationif (digitalRead(EXPOSURE) == LOW){ // has exposure button been pressedexposure();
}
}
The text was updated successfully, but these errors were encountered:
I have included notes in the following code describing what I am trying to accomplish and some of the many attempts I've made to come up with logic to make it work. I'm not sophisticated at programming, though I have made a variety of successful projects with non-Arduino systems. For some (probably obvious) reason, this one eludes me.
The text was updated successfully, but these errors were encountered: