// määritetään askelmoottorin ohjaimen pinnit 9 askellus, 8 suunta
// define stepper motor driver pins: 9 for step, 8 for direction
// määritetään painikkeiden pinnit arduinolle
// define button pins for the Arduino
#define PAALLENAPPI_PIN 4
// #define POWER_BUTTON_PIN 4
#define YLARAJA_PIN 3
// #define UPPER_LIMIT_PIN 3
#define ALARAJA_PIN 2
// #define LOWER_LIMIT_PIN 2
#define HIDASTUS_PIN 5
// #define SLOWDOWN_PIN 5
// määritetään nopeus säädön potikka analogia pinni
// define analog pin for speed-control potentiometer
// määritetään maksimi ja minimi askelnopeus sekuntia kohden (skaalaa potikan tähän väliin)
// define max and min step rate per second (scale the potentiometer to this range)
// säädetään askelmoottorin maximi pyörimisnopeus
// set the stepper motor's maximum rotation speed
// Asetetaan antureiden ja painonapin nappityyppi. input_pullupit tarkoittaa, että käytössä ylösvetovastuksilla toteutettu toiminta
// Set sensor and button input types. INPUT_PULLUP means internal pull-up resistors are used
// 1 kelkka liikkuu ylöspäin
// 1 = carriage moves upward
// -1 kelkka liikkuu alaspäin
// -1 = carriage moves downward
// 0 kelkka pysähtyy
// 0 = carriage stops
// jos anturi tai painonappi on aktiivinen, seuraava merkki kirjoitetaan ohjelmaan(sign)
// if a sensor or button is active, the following sign value is written to the program
// potikkaa(nopeutta luetaan silloin tällöin (koska se ottaa ohjelmassa pitkän ajan
// eikä sitä haluta tehdä koko ajan pääsilmukassa)
// the potentiometer (speed) is read only occasionally (because it takes a long time and shouldn't run continuously in the main loop)
// skaalataan potikan arvo minimistä maksiminopeuteen
// scale the potentiometer value from minimum to maximum speed
// päivitetään askelmoottorin nopeus uuteen arvoon
// update the stepper motor speed to the new value
// tämä ajaa askelmoottoria vakionopeudella
// this runs the stepper motor at a constant speed
I've been in the garage tonight working on the mechanics of a wobbler varnishing machine and it seems that a lot of things have come up in the thread. It's good that this is causing a discussion. Maybe I'll learn to code too one day mechanics and electrical work are closer to my heart at the moment I could of course post a picture of my device here, but I don't know if I can put it on display here somehow? Of course, when it's finished...
pinMode(PAALLENAPPI_PIN, INPUT_PULLUP); is for buttons providing a Gnd contact. If your provides a 5V, that means an external pull-down resistor is connected to Gnd (4.7K or 10K probably) and you need to code it this way (to also remove ambiguity)
pinMode(PAALLENAPPI_PIN, INPUT);
or nothing at all for this pin as it is the default state anyway.
How are the 3 switches connected ? To Gnd or +5V ?
+5v or do you mean limit sensors? reed switches are of the pnp type, meaning that when the limit is reached, a voltage is applied. A pull-down resistor is connected to this, which drops the voltage to 5 volts. So I'm using 24 volts because I work in industrial automation and this is a voltage I'm familiar with...
A simple schematic, drawn on an envelope with a pencil, then snapshotted with a phone and posted in a new message here, would remove so much ambiguity about how you presently have the circuit wired. Please, for the sake of everyone, provide one.