Replacing a 10k potentiometer with a programmable timer

I implemented what I believe is your circuit

and I have a doubt: you use INPUT_PULLUP but are your switches (and buttons) connected to GND or to +5V ?
I mean:

if ((digitalRead(PAALLENAPPI_PIN) == 1)...

means PAALLENAPPI btn provides a 5V when pressed...

1 Like

For anyone whose Finnish is a bit rusty:

// 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

HTH

a7

Yes. When you press the button, it will take about 5 v.

My question was about voltages, not timing. Is the button connected to ground (0V) or 5V ?

sorry for the google translator error :slight_smile: When you press the button, a voltage of about 5 volts is generated

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 :slight_smile: mechanics and electrical work are closer to my heart at the moment :slight_smile: 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...

Since all buttons and switches provide +5v, remove all the INPUT_PULLUP statements, they fight against the pull-down resistors.

And if you want to tinker with my Wokwi, you'll have to modify the buttons connection to reflect your contraption...

I hope it is a resistive voltage divider, not a simple pull-down resistor...

The edition window displays a HDD symbol with an arrow pointing up, this allows you to upload files such as pictures, pdf...

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.