Need help with arduino vending machine

Hello,

I am new here and I have no experience with arduino. I apologize if I am posting the question incorrectly.

Here is what I need help with. I have bought a diy vending machine which someone made and it runs on arduino. It has a coin acceptor, the model is CH-926, it has one lcd screen, a microcontroler MEGA 2560, 4 relays on the relay module and 4 step motors.

Everything works fine, but the only issue is that he programmed it to count cents in the local currency. So for example if somebody puts in lets say 5 coins the machine counts as +10 cents and +10 cents and +10 cents and this takes about 10 to 20 seconds to get to the sum of 5 because 1 coin equals to 10 times 10 cents so 100 cents. Is there a way to program the arduino code so that it only counts the coins not cents, so if 1 is inserted five times it's +1 +1 +1 +1 +1. Also the machine is programed to refuse cents, it only accepts coins, but it unfortunately counts the coins as cents. Is this problem solvable?
In the local currency here we have a coin of 1, 2 and 5. The cents are irrelevant and I do not want the machine to use them or count the coins as cents. I hope you understand me.

I again apologize if I am writing my question in a wrong way and any help would be very much appreciated.

Thank you.

This is the code and I apologize if I copied the wrong thing, this code was sent to me by the man who sold me the machine, he said it's the code to change the price:

const int cijena1 = 100 ;
const int cijena2 = 100 ;
const int cijena3 = 100 ;
const int cijena4 = 100 ;


                                                                                                                                                                                                float Cijena1 = cijena1; float Cijena2 = cijena2; float Cijena3 = cijena3; float Cijena4 = cijena4; int SetUp = 0; void coinInterrupt(){  cents = cents + 1; CurrentMillis = millis ();} void setup() { pinMode (4, OUTPUT); pinMode (5, OUTPUT); pinMode (6, OUTPUT); pinMode (7, OUTPUT); digitalWrite (4, HIGH); digitalWrite (5, HIGH); digitalWrite (6, HIGH); digitalWrite (7, HIGH); pinMode (8, INPUT); pinMode (9, INPUT); pinMode (10, INPUT); pinMode (11, INPUT); pinMode (12, INPUT); SetUp = digitalRead (12); delay(1); stepper1.setMaxSpeed(2000.0); stepper1.move(1); stepper1.move(-1); stepper1.setSpeed(stepperSpeed); stepper1.setCurrentPosition (0); stepper2.setMaxSpeed(2000.0); stepper2.move(1); stepper2.move(-1); stepper2.setSpeed(stepperSpeed); stepper2.setCurrentPosition (0); stepper3.setMaxSpeed(2000.0); stepper3.move(1); stepper3.move(-1); stepper3.setSpeed(stepperSpeed); stepper3.setCurrentPosition (0); stepper4.setMaxSpeed(2000.0); stepper4.move(1); stepper4.move(-1); stepper4.setSpeed(stepperSpeed); stepper4.setCurrentPosition (0); attachInterrupt(digitalPinToInterrupt(2), coinInterrupt, RISING); lcd.begin(); lcd.backlight (); }
                                                                                                                                                                                                void loop() { kredit = cents ; Kredit = cents ; if (SetUp == HIGH) { pb1 = digitalRead(8); pb2 = digitalRead(9); pb3 = digitalRead(10); pb4 = digitalRead(11); if (pb1 == LOW && pb2 == LOW && pb3 == LOW && pb4 == LOW) { lcd.setCursor(0,0); lcd.print("   CONDOMISMA   ");  lcd.setCursor(0,1); lcd.print("   SetUp mode   "); digitalWrite (4, HIGH); digitalWrite (5, HIGH); digitalWrite (6, HIGH); digitalWrite (7, HIGH); } else if (pb1 == HIGH && pb2 == LOW && pb3 == LOW && pb4 == LOW) { digitalWrite (4, LOW); stepper1.move(5000); stepper1.setSpeed(700); stepper1.run();} else if (pb2 == HIGH && pb1 == LOW && pb3 == LOW && pb4 == LOW) { digitalWrite (5, LOW); stepper2.move(5000); stepper2.setSpeed(700); stepper2.run(); } else if (pb3 == HIGH && pb2 == LOW && pb1 == LOW && pb4 == LOW) { digitalWrite (6, LOW); stepper3.move(5000); stepper3.setSpeed(700); stepper3.run(); } else if (pb4 == HIGH && pb2 == LOW && pb3 == LOW && pb1 == LOW) { digitalWrite (7, LOW); stepper4.move(5000); stepper4.setSpeed(700); stepper4.run(); } } else if (SetUp == LOW) { if (pb1 == LOW && pb2 == LOW && pb3 == LOW && pb4 == LOW){  if (cents > 0) { lcd.setCursor(0,0); lcd.print("                "); lcd.setCursor(1,1); lcd.print("Kredit="); lcd.print (Kredit/10); lcd.print("KM");} if (cents <= 0) { lcd.setCursor(0,0); lcd.print("    SUVENIRI    "); lcd.setCursor(0,1); lcd.print("   SOUVENIRS    ");}} /* 1 */ if (stepper1.distanceToGo() == 0) {pb1 = digitalRead(8);} if (pb1 == HIGH && pb2 == LOW && pb3 == LOW && pb4 == LOW && kredit >= cijena1) { digitalWrite (4, LOW); buttonState1 = HIGH; CurrentMillis = millis ();} if (buttonState1 == HIGH ) { stepper1.moveTo(4103); stepper1.setSpeed(stepperSpeed); stepper1.runSpeedToPosition(); if (stepper1.distanceToGo() == 0) { stepper1.setCurrentPosition (0); cents = cents - cijena1; delay (300); digitalWrite (4, HIGH); buttonState1 = LOW; lcd.setCursor(0,0); lcd.print("     Hvala!     "); lcd.setCursor(1,1); lcd.print("Vidimo se opet "); delay (3000); }} else if (pb1 == HIGH && pb2 == LOW && pb3 == LOW && pb4 == LOW && kredit < cijena1) { lcd.setCursor(0,0); lcd.print("                "); lcd.print (Cijena1/10); lcd.print (""); lcd.setCursor(1,1); lcd.print("Kredit="); lcd.print (Kredit/10); lcd.print("KM "); delay (2000);}  /* 4 */ if (stepper4.distanceToGo() == 0) { pb4 = digitalRead(11);} if (pb4 == HIGH && pb2 == LOW && pb3 == LOW && pb1 == LOW && kredit >= cijena4) { digitalWrite (7, LOW); buttonState4 = HIGH; CurrentMillis = millis ();} if (buttonState4 == HIGH) { stepper4.moveTo(4103); stepper4.setSpeed(stepperSpeed); stepper4.runSpeedToPosition(); if (stepper4.distanceToGo() == 0) { stepper4.setCurrentPosition (0); cents = cents - cijena4; delay (300); digitalWrite (7, HIGH); buttonState4 = LOW; lcd.setCursor(0,0); lcd.print("     Hvala!     ");lcd.setCursor(1,1); lcd.print("Vidimo se opet "); delay (3000);}} else if (pb1 == LOW && pb2 == LOW && pb3 == LOW && pb4 == HIGH && kredit < cijena4) {  lcd.setCursor(0,0); lcd.print("                "); lcd.print (Cijena4/10); lcd.print (""); lcd.setCursor(1,1); lcd.print("Kredit="); lcd.print (Kredit/10); lcd.print("KM  "); delay (2000);}  /*2*/ if (stepper2.distanceToGo() == 0) { pb2 = digitalRead(9);} if (pb2 == HIGH && pb1 == LOW && pb3 == LOW && pb4 == LOW && kredit >= cijena2) { digitalWrite (5, LOW); buttonState2 = HIGH; CurrentMillis = millis ();} if (buttonState2 == HIGH) { stepper2.moveTo(4103); stepper2.setSpeed(stepperSpeed); stepper2.runSpeedToPosition(); if (stepper2.distanceToGo() == 0) { stepper2.setCurrentPosition (0); cents = cents - cijena2; delay (300); digitalWrite (5, HIGH); buttonState2 = LOW; lcd.setCursor(0,0); lcd.print("     Hvala!     "); lcd.setCursor(1,1); lcd.print("Vidimo se opet "); delay (3000);}} else if (pb1 == LOW && pb2 == HIGH && pb3 == LOW && pb4 == LOW && kredit < cijena2) { lcd.setCursor(0,0); lcd.print("                "); lcd.print (Cijena2/10); lcd.print ("");  lcd.setCursor(1,1); lcd.print("Kredit="); lcd.print (Kredit/10); lcd.print("KM "); delay (2000);} /* 3 */ if (stepper3.distanceToGo() == 0) { pb3 = digitalRead(10);} if (pb3 == HIGH && pb2 == LOW && pb1 == LOW && pb4 == LOW && kredit >= cijena3) { digitalWrite (6, LOW); buttonState3 = HIGH; CurrentMillis = millis ();} if (buttonState3 == HIGH) { stepper3.moveTo(4103); stepper3.setSpeed(stepperSpeed); stepper3.runSpeedToPosition(); if (stepper3.distanceToGo() == 0) { stepper3.setCurrentPosition (0); cents = cents - cijena3; delay (300); digitalWrite (6, HIGH); buttonState3 = LOW; lcd.setCursor(0,0); lcd.print("     Hvala!     "); lcd.setCursor(1,1); lcd.print("Vidimo se opet "); delay (3000);}} else if (pb1 == LOW && pb2 == LOW && pb3 == HIGH && pb4 == LOW && kredit < cijena3) { lcd.setCursor(0,0); lcd.print("                "); lcd.print (Cijena3/10); lcd.print (""); lcd.setCursor(1,1); lcd.print("Kredit="); lcd.print (Kredit/10); lcd.print("KM  "); delay (2000);} } if (pb3 == HIGH || pb2 == HIGH || pb1 == HIGH || pb4 == HIGH) { CurrentMillis = millis ();} if (millis () - CurrentMillis >= 300000UL) {cents = 0; CurrentMillis = millis ();} }
                                                                                                                                                                                                

First of all, what is exactly that "coin" value for you, and how is it related to "cents" (btw, also "cents" are "coins")? For instance, does a "coin" is either 10 cents or 1 Euro, Dollar, whatever?

Sorry, I can't follow you here.
Let's say your currency is Euro, just to try making things easier to understand, and you have coins for 1, 2 and 5 cents.
In your example, are you saying that inserting 1 Euro (that is obviously 100 cents), the code adds just 10 cents instead of 100? And are you sure the coin acceptor can distinguish between the single coin values (1 cent, 2 cents, 5 cents, 1 Euro)? And do you want to accept and count just Euros and none of the "cents"?

I must ask you to clarify this topic (and what currency we're taliknig about), together with the full Arduino code (post it under "code" tags...), and a link to the exact coin acceptor you're using, to try and understand its capabilities.

Hello,

Thank you very much for replying.
This is the link to the coin acceptor:
https://www.aliexpress.com/item/32843324092.html
The name of the coin acceptor is CH-926.
Let's say that the 1 coin is 1 Euro so, when you insert 1 Euro coin the maching won't instantly count it as 1 Euro but it will slowly add 0.10, 0.20. 0.30, 0,40 all until it reaches 1 Euro. Althought the machine is set not to accept anything below 1 Euro. So imagine if the price is 10 Euros in coins it takes about half a minute to count all the way up to 10 Euros if you insert enough 1 or 2 or 5 coins. It's like okay 0.10, 0.20, 0.30 then once it hits 1 Euro it counts 1.10, 1.20, 1.30 and so on. I apologize if I didn't explain this well.

Maybe this is a stupid question, but how do I get the full arduino code?

Thank you again

It sounds like the coin acceptor is configured to send 10 pulses for a 1-euro coin. To get it to send only one pulse, you will need to change the coin acceptor configuration. Have you found documentation for changing the configuration of your coin acceptor?

This is the code after formatting:

const int cijena1 = 100;
const int cijena2 = 100;
const int cijena3 = 100;
const int cijena4 = 100;


float Cijena1 = cijena1;
float Cijena2 = cijena2;
float Cijena3 = cijena3;
float Cijena4 = cijena4;
int SetUp = 0;
void coinInterrupt()
{
  cents = cents + 1;
  CurrentMillis = millis();
}
void setup()
{
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  pinMode(8, INPUT);
  pinMode(9, INPUT);
  pinMode(10, INPUT);
  pinMode(11, INPUT);
  pinMode(12, INPUT);
  SetUp = digitalRead(12);
  delay(1);
  stepper1.setMaxSpeed(2000.0);
  stepper1.move(1);
  stepper1.move(-1);
  stepper1.setSpeed(stepperSpeed);
  stepper1.setCurrentPosition(0);
  stepper2.setMaxSpeed(2000.0);
  stepper2.move(1);
  stepper2.move(-1);
  stepper2.setSpeed(stepperSpeed);
  stepper2.setCurrentPosition(0);
  stepper3.setMaxSpeed(2000.0);
  stepper3.move(1);
  stepper3.move(-1);
  stepper3.setSpeed(stepperSpeed);
  stepper3.setCurrentPosition(0);
  stepper4.setMaxSpeed(2000.0);
  stepper4.move(1);
  stepper4.move(-1);
  stepper4.setSpeed(stepperSpeed);
  stepper4.setCurrentPosition(0);
  attachInterrupt(digitalPinToInterrupt(2), coinInterrupt, RISING);
  lcd.begin();
  lcd.backlight();
}
void loop()
{
  kredit = cents;
  Kredit = cents;
  if (SetUp == HIGH)
  {
    pb1 = digitalRead(8);
    pb2 = digitalRead(9);
    pb3 = digitalRead(10);
    pb4 = digitalRead(11);
    if (pb1 == LOW && pb2 == LOW && pb3 == LOW && pb4 == LOW)
    {
      lcd.setCursor(0, 0);
      lcd.print("   CONDOMISMA   ");
      lcd.setCursor(0, 1);
      lcd.print("   SetUp mode   ");
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, HIGH);
      digitalWrite(7, HIGH);
    }
    else if (pb1 == HIGH && pb2 == LOW && pb3 == LOW && pb4 == LOW)
    {
      digitalWrite(4, LOW);
      stepper1.move(5000);
      stepper1.setSpeed(700);
      stepper1.run();
    }
    else if (pb2 == HIGH && pb1 == LOW && pb3 == LOW && pb4 == LOW)
    {
      digitalWrite(5, LOW);
      stepper2.move(5000);
      stepper2.setSpeed(700);
      stepper2.run();
    }
    else if (pb3 == HIGH && pb2 == LOW && pb1 == LOW && pb4 == LOW)
    {
      digitalWrite(6, LOW);
      stepper3.move(5000);
      stepper3.setSpeed(700);
      stepper3.run();
    }
    else if (pb4 == HIGH && pb2 == LOW && pb3 == LOW && pb1 == LOW)
    {
      digitalWrite(7, LOW);
      stepper4.move(5000);
      stepper4.setSpeed(700);
      stepper4.run();
    }
  }
  else if (SetUp == LOW)
  {
    if (pb1 == LOW && pb2 == LOW && pb3 == LOW && pb4 == LOW)
    {
      if (cents > 0)
      {
        lcd.setCursor(0, 0);
        lcd.print("                ");
        lcd.setCursor(1, 1);
        lcd.print("Kredit=");
        lcd.print(Kredit / 10);
        lcd.print("KM");
      }
      if (cents <= 0)
      {
        lcd.setCursor(0, 0);
        lcd.print("    SUVENIRI    ");
        lcd.setCursor(0, 1);
        lcd.print("   SOUVENIRS    ");
      }
    } /* 1 */
    if (stepper1.distanceToGo() == 0) { pb1 = digitalRead(8); }
    if (pb1 == HIGH && pb2 == LOW && pb3 == LOW && pb4 == LOW && kredit >= cijena1)
    {
      digitalWrite(4, LOW);
      buttonState1 = HIGH;
      CurrentMillis = millis();
    }
    if (buttonState1 == HIGH)
    {
      stepper1.moveTo(4103);
      stepper1.setSpeed(stepperSpeed);
      stepper1.runSpeedToPosition();
      if (stepper1.distanceToGo() == 0)
      {
        stepper1.setCurrentPosition(0);
        cents = cents - cijena1;
        delay(300);
        digitalWrite(4, HIGH);
        buttonState1 = LOW;
        lcd.setCursor(0, 0);
        lcd.print("     Hvala!     ");
        lcd.setCursor(1, 1);
        lcd.print("Vidimo se opet ");
        delay(3000);
      }
    }
    else if (pb1 == HIGH && pb2 == LOW && pb3 == LOW && pb4 == LOW && kredit < cijena1)
    {
      lcd.setCursor(0, 0);
      lcd.print("                ");
      lcd.print(Cijena1 / 10);
      lcd.print("");
      lcd.setCursor(1, 1);
      lcd.print("Kredit=");
      lcd.print(Kredit / 10);
      lcd.print("KM ");
      delay(2000);
    } /* 4 */
    if (stepper4.distanceToGo() == 0) { pb4 = digitalRead(11); }
    if (pb4 == HIGH && pb2 == LOW && pb3 == LOW && pb1 == LOW && kredit >= cijena4)
    {
      digitalWrite(7, LOW);
      buttonState4 = HIGH;
      CurrentMillis = millis();
    }
    if (buttonState4 == HIGH)
    {
      stepper4.moveTo(4103);
      stepper4.setSpeed(stepperSpeed);
      stepper4.runSpeedToPosition();
      if (stepper4.distanceToGo() == 0)
      {
        stepper4.setCurrentPosition(0);
        cents = cents - cijena4;
        delay(300);
        digitalWrite(7, HIGH);
        buttonState4 = LOW;
        lcd.setCursor(0, 0);
        lcd.print("     Hvala!     ");
        lcd.setCursor(1, 1);
        lcd.print("Vidimo se opet ");
        delay(3000);
      }
    }
    else if (pb1 == LOW && pb2 == LOW && pb3 == LOW && pb4 == HIGH && kredit < cijena4)
    {
      lcd.setCursor(0, 0);
      lcd.print("                ");
      lcd.print(Cijena4 / 10);
      lcd.print("");
      lcd.setCursor(1, 1);
      lcd.print("Kredit=");
      lcd.print(Kredit / 10);
      lcd.print("KM  ");
      delay(2000);
    } /*2*/
    if (stepper2.distanceToGo() == 0) { pb2 = digitalRead(9); }
    if (pb2 == HIGH && pb1 == LOW && pb3 == LOW && pb4 == LOW && kredit >= cijena2)
    {
      digitalWrite(5, LOW);
      buttonState2 = HIGH;
      CurrentMillis = millis();
    }
    if (buttonState2 == HIGH)
    {
      stepper2.moveTo(4103);
      stepper2.setSpeed(stepperSpeed);
      stepper2.runSpeedToPosition();
      if (stepper2.distanceToGo() == 0)
      {
        stepper2.setCurrentPosition(0);
        cents = cents - cijena2;
        delay(300);
        digitalWrite(5, HIGH);
        buttonState2 = LOW;
        lcd.setCursor(0, 0);
        lcd.print("     Hvala!     ");
        lcd.setCursor(1, 1);
        lcd.print("Vidimo se opet ");
        delay(3000);
      }
    }
    else if (pb1 == LOW && pb2 == HIGH && pb3 == LOW && pb4 == LOW && kredit < cijena2)
    {
      lcd.setCursor(0, 0);
      lcd.print("                ");
      lcd.print(Cijena2 / 10);
      lcd.print("");
      lcd.setCursor(1, 1);
      lcd.print("Kredit=");
      lcd.print(Kredit / 10);
      lcd.print("KM ");
      delay(2000);
    } /* 3 */
    if (stepper3.distanceToGo() == 0) { pb3 = digitalRead(10); }
    if (pb3 == HIGH && pb2 == LOW && pb1 == LOW && pb4 == LOW && kredit >= cijena3)
    {
      digitalWrite(6, LOW);
      buttonState3 = HIGH;
      CurrentMillis = millis();
    }
    if (buttonState3 == HIGH)
    {
      stepper3.moveTo(4103);
      stepper3.setSpeed(stepperSpeed);
      stepper3.runSpeedToPosition();
      if (stepper3.distanceToGo() == 0)
      {
        stepper3.setCurrentPosition(0);
        cents = cents - cijena3;
        delay(300);
        digitalWrite(6, HIGH);
        buttonState3 = LOW;
        lcd.setCursor(0, 0);
        lcd.print("     Hvala!     ");
        lcd.setCursor(1, 1);
        lcd.print("Vidimo se opet ");
        delay(3000);
      }
    }
    else if (pb1 == LOW && pb2 == LOW && pb3 == HIGH && pb4 == LOW && kredit < cijena3)
    {
      lcd.setCursor(0, 0);
      lcd.print("                ");
      lcd.print(Cijena3 / 10);
      lcd.print("");
      lcd.setCursor(1, 1);
      lcd.print("Kredit=");
      lcd.print(Kredit / 10);
      lcd.print("KM  ");
      delay(2000);
    }
  }
  if (pb3 == HIGH || pb2 == HIGH || pb1 == HIGH || pb4 == HIGH) { CurrentMillis = millis(); }
  if (millis() - CurrentMillis >= 300000UL)
  {
    cents = 0;
    CurrentMillis = millis();
  }
}

Hello,

That might be the issue.

Wow, you clearly know what you're doing. So this is the correct code?
So I need to input this into the machine?
Now I need to figure out how to do that.
I am also amazed how you got to display the code like that, I mean one line of code under another and not like I displayed it in one long line.

Thank you

I have never had to do with it, but as far as I can see after a brief google, it is cheap but programmable and able to recognise up to 6 kind/value of coins!

Have a look at THIS project from Instructables site, looks like a useful source for you to learn more about the coin acceptor and how to interface it with Arduino (to let you then change/adapt your code).

The instruction manual for the coin mechanism is here.

It can be programmed to accept up to 6 different coin types.
The 'value' of each coin type is indicated by the number of pulses it is programmed to send out - this can be up to 50.

There is a switch that selects three different output pulse widths - fast: 20ms , medium: 50ms , slow: 100ms.

Check which position it is in. - If it is set to "slow" that would explain why it takes so long for the Arduino to count the pulses.

You should be able to use "fast", as the sketch uses an interrupt to update the credit.

PS: the code you posted here seems to me isn't properly a good programming style, maybe made by more than one people, with some "mixed logic". For example where does "cents" variable is defined and initilized? Why int variables ("cijena*") copied into float ones with very similar names except the first letter ("Cijena*"), and used only once around? What is that 100 as their initial value? If it is cents, why not divide it by 100 when adding to the float to get a "real" currency value? And so on...

Even I who knows nothing about programing can see that it's not properly programmed. The man above who posted the correction of the code wrote it properly. Now I am trying to figure out how to input this correct code into the arduino, but I can't figure it out for the life of me. I apologize again and just want to remind everyone again that I really know nothing about arduino, I am just trying to fix a I hope "simple" code issue for the machine to work properly.

Thank you again.

Hello pumpa123

Here comes my standard recipe:

Take a piece of paper, a pencil and design, based on the IPO model, a program structure plan before start coding.
Identify functions and their depencies. Now start with coding and testing, function by function.
At the end merge all tested function together to get the final sketch.
The basics for coding the project are to be found in the IDE as examples.

Have a nice day and enjoy coding in C++.

p.s. In general, you should not use magic numbers. The I/O pins love to have a functional name.

Sorry, but this sounds like "I know nothing of engines, but I try to change the compression ratio of the car I bought, replacing the existing head gaskets".

If you know nothing about Arduino and want to modify a badly written code, it's a hard thing to do for you, and it may just lead you to have a headache. And it's a quite heavy task for us, trying to understand what you want to achieve, what that code really does, and how to change it to meet your goals.
The only hint I can give you is to have a look at the Instructable project I posted before, and start from there.

I am sorry that I don't know much about arduino. I am just trying to fix this issue, perhaps I should seek professional help with this? I thought that this forum could help me fix the problem and I hoped that the problem is simple to solve. But looks like it isn't.

I thought that the code which the man uploaded above is the solution? This code:

const int cijena1 = 100;
const int cijena2 = 100;
const int cijena3 = 100;
const int cijena4 = 100;


float Cijena1 = cijena1;
float Cijena2 = cijena2;
float Cijena3 = cijena3;
float Cijena4 = cijena4;
int SetUp = 0;
void coinInterrupt()
{
  cents = cents + 1;
  CurrentMillis = millis();
}
void setup()
{
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  digitalWrite(6, HIGH);
  digitalWrite(7, HIGH);
  pinMode(8, INPUT);
  pinMode(9, INPUT);
  pinMode(10, INPUT);
  pinMode(11, INPUT);
  pinMode(12, INPUT);
  SetUp = digitalRead(12);
  delay(1);
  stepper1.setMaxSpeed(2000.0);
  stepper1.move(1);
  stepper1.move(-1);
  stepper1.setSpeed(stepperSpeed);
  stepper1.setCurrentPosition(0);
  stepper2.setMaxSpeed(2000.0);
  stepper2.move(1);
  stepper2.move(-1);
  stepper2.setSpeed(stepperSpeed);
  stepper2.setCurrentPosition(0);
  stepper3.setMaxSpeed(2000.0);
  stepper3.move(1);
  stepper3.move(-1);
  stepper3.setSpeed(stepperSpeed);
  stepper3.setCurrentPosition(0);
  stepper4.setMaxSpeed(2000.0);
  stepper4.move(1);
  stepper4.move(-1);
  stepper4.setSpeed(stepperSpeed);
  stepper4.setCurrentPosition(0);
  attachInterrupt(digitalPinToInterrupt(2), coinInterrupt, RISING);
  lcd.begin();
  lcd.backlight();
}
void loop()
{
  kredit = cents;
  Kredit = cents;
  if (SetUp == HIGH)
  {
    pb1 = digitalRead(8);
    pb2 = digitalRead(9);
    pb3 = digitalRead(10);
    pb4 = digitalRead(11);
    if (pb1 == LOW && pb2 == LOW && pb3 == LOW && pb4 == LOW)
    {
      lcd.setCursor(0, 0);
      lcd.print("   CONDOMISMA   ");
      lcd.setCursor(0, 1);
      lcd.print("   SetUp mode   ");
      digitalWrite(4, HIGH);
      digitalWrite(5, HIGH);
      digitalWrite(6, HIGH);
      digitalWrite(7, HIGH);
    }
    else if (pb1 == HIGH && pb2 == LOW && pb3 == LOW && pb4 == LOW)
    {
      digitalWrite(4, LOW);
      stepper1.move(5000);
      stepper1.setSpeed(700);
      stepper1.run();
    }
    else if (pb2 == HIGH && pb1 == LOW && pb3 == LOW && pb4 == LOW)
    {
      digitalWrite(5, LOW);
      stepper2.move(5000);
      stepper2.setSpeed(700);
      stepper2.run();
    }
    else if (pb3 == HIGH && pb2 == LOW && pb1 == LOW && pb4 == LOW)
    {
      digitalWrite(6, LOW);
      stepper3.move(5000);
      stepper3.setSpeed(700);
      stepper3.run();
    }
    else if (pb4 == HIGH && pb2 == LOW && pb3 == LOW && pb1 == LOW)
    {
      digitalWrite(7, LOW);
      stepper4.move(5000);
      stepper4.setSpeed(700);
      stepper4.run();
    }
  }
  else if (SetUp == LOW)
  {
    if (pb1 == LOW && pb2 == LOW && pb3 == LOW && pb4 == LOW)
    {
      if (cents > 0)
      {
        lcd.setCursor(0, 0);
        lcd.print("                ");
        lcd.setCursor(1, 1);
        lcd.print("Kredit=");
        lcd.print(Kredit / 10);
        lcd.print("KM");
      }
      if (cents <= 0)
      {
        lcd.setCursor(0, 0);
        lcd.print("    SUVENIRI    ");
        lcd.setCursor(0, 1);
        lcd.print("   SOUVENIRS    ");
      }
    } /* 1 */
    if (stepper1.distanceToGo() == 0) { pb1 = digitalRead(8); }
    if (pb1 == HIGH && pb2 == LOW && pb3 == LOW && pb4 == LOW && kredit >= cijena1)
    {
      digitalWrite(4, LOW);
      buttonState1 = HIGH;
      CurrentMillis = millis();
    }
    if (buttonState1 == HIGH)
    {
      stepper1.moveTo(4103);
      stepper1.setSpeed(stepperSpeed);
      stepper1.runSpeedToPosition();
      if (stepper1.distanceToGo() == 0)
      {
        stepper1.setCurrentPosition(0);
        cents = cents - cijena1;
        delay(300);
        digitalWrite(4, HIGH);
        buttonState1 = LOW;
        lcd.setCursor(0, 0);
        lcd.print("     Hvala!     ");
        lcd.setCursor(1, 1);
        lcd.print("Vidimo se opet ");
        delay(3000);
      }
    }
    else if (pb1 == HIGH && pb2 == LOW && pb3 == LOW && pb4 == LOW && kredit < cijena1)
    {
      lcd.setCursor(0, 0);
      lcd.print("                ");
      lcd.print(Cijena1 / 10);
      lcd.print("");
      lcd.setCursor(1, 1);
      lcd.print("Kredit=");
      lcd.print(Kredit / 10);
      lcd.print("KM ");
      delay(2000);
    } /* 4 */
    if (stepper4.distanceToGo() == 0) { pb4 = digitalRead(11); }
    if (pb4 == HIGH && pb2 == LOW && pb3 == LOW && pb1 == LOW && kredit >= cijena4)
    {
      digitalWrite(7, LOW);
      buttonState4 = HIGH;
      CurrentMillis = millis();
    }
    if (buttonState4 == HIGH)
    {
      stepper4.moveTo(4103);
      stepper4.setSpeed(stepperSpeed);
      stepper4.runSpeedToPosition();
      if (stepper4.distanceToGo() == 0)
      {
        stepper4.setCurrentPosition(0);
        cents = cents - cijena4;
        delay(300);
        digitalWrite(7, HIGH);
        buttonState4 = LOW;
        lcd.setCursor(0, 0);
        lcd.print("     Hvala!     ");
        lcd.setCursor(1, 1);
        lcd.print("Vidimo se opet ");
        delay(3000);
      }
    }
    else if (pb1 == LOW && pb2 == LOW && pb3 == LOW && pb4 == HIGH && kredit < cijena4)
    {
      lcd.setCursor(0, 0);
      lcd.print("                ");
      lcd.print(Cijena4 / 10);
      lcd.print("");
      lcd.setCursor(1, 1);
      lcd.print("Kredit=");
      lcd.print(Kredit / 10);
      lcd.print("KM  ");
      delay(2000);
    } /*2*/
    if (stepper2.distanceToGo() == 0) { pb2 = digitalRead(9); }
    if (pb2 == HIGH && pb1 == LOW && pb3 == LOW && pb4 == LOW && kredit >= cijena2)
    {
      digitalWrite(5, LOW);
      buttonState2 = HIGH;
      CurrentMillis = millis();
    }
    if (buttonState2 == HIGH)
    {
      stepper2.moveTo(4103);
      stepper2.setSpeed(stepperSpeed);
      stepper2.runSpeedToPosition();
      if (stepper2.distanceToGo() == 0)
      {
        stepper2.setCurrentPosition(0);
        cents = cents - cijena2;
        delay(300);
        digitalWrite(5, HIGH);
        buttonState2 = LOW;
        lcd.setCursor(0, 0);
        lcd.print("     Hvala!     ");
        lcd.setCursor(1, 1);
        lcd.print("Vidimo se opet ");
        delay(3000);
      }
    }
    else if (pb1 == LOW && pb2 == HIGH && pb3 == LOW && pb4 == LOW && kredit < cijena2)
    {
      lcd.setCursor(0, 0);
      lcd.print("                ");
      lcd.print(Cijena2 / 10);
      lcd.print("");
      lcd.setCursor(1, 1);
      lcd.print("Kredit=");
      lcd.print(Kredit / 10);
      lcd.print("KM ");
      delay(2000);
    } /* 3 */
    if (stepper3.distanceToGo() == 0) { pb3 = digitalRead(10); }
    if (pb3 == HIGH && pb2 == LOW && pb1 == LOW && pb4 == LOW && kredit >= cijena3)
    {
      digitalWrite(6, LOW);
      buttonState3 = HIGH;
      CurrentMillis = millis();
    }
    if (buttonState3 == HIGH)
    {
      stepper3.moveTo(4103);
      stepper3.setSpeed(stepperSpeed);
      stepper3.runSpeedToPosition();
      if (stepper3.distanceToGo() == 0)
      {
        stepper3.setCurrentPosition(0);
        cents = cents - cijena3;
        delay(300);
        digitalWrite(6, HIGH);
        buttonState3 = LOW;
        lcd.setCursor(0, 0);
        lcd.print("     Hvala!     ");
        lcd.setCursor(1, 1);
        lcd.print("Vidimo se opet ");
        delay(3000);
      }
    }
    else if (pb1 == LOW && pb2 == LOW && pb3 == HIGH && pb4 == LOW && kredit < cijena3)
    {
      lcd.setCursor(0, 0);
      lcd.print("                ");
      lcd.print(Cijena3 / 10);
      lcd.print("");
      lcd.setCursor(1, 1);
      lcd.print("Kredit=");
      lcd.print(Kredit / 10);
      lcd.print("KM  ");
      delay(2000);
    }
  }
  if (pb3 == HIGH || pb2 == HIGH || pb1 == HIGH || pb4 == HIGH) { CurrentMillis = millis(); }
  if (millis() - CurrentMillis >= 300000UL)
  {
    cents = 0;
    CurrentMillis = millis();
  }
}

I found the switch, fast, medium, slow. It was set to slow, now it's set to fast and it went from originally about 20+ seconds to count to 10 to about 13 seconds to count to 10 now. However it still counts 0.10, 0.20....3.10...3.20....3.30.....9.10...9.50...9.60...9.90 all the way up to 10. Just don't know what to do.

Sounds like you can set your coin acceptor to produce 1 pulse for a 1KM coin, 2 pulses for a 2KM coin, and 5 pulses for a 5KM coin. Then your 'coin", 'kredit' and 'Kredit' variables will be in KM.

You would then change the price ('cijena') values to the prices in KM for the four products.

Cijena

it is translated "price"

Yes that's exactly what it means

I know how to change the coin acceptor pulses. The problem I have is that the guy who programmed the microcontroller set the value of 1 coin equal to 10 pulses and each puls equals 10 cents. Now if I change everything how you said, I can't upload the code-sketch into the microcontroler. The type is Arduino MEGA 2560
When I click on verify it gives me this error message:

Compilation error: 'cents' was not declared in this scope

What am I doing wrong now?

So cijena or price 1 is equal to 1 and not 100?
Price 2 is 2
Price 3 is 5?

I am confused
I am sorry

PS

The price is the same for all 4 products it's 10

The code you have posted is very incomplete. Either you lost part of it when posting or the code was missing parts when you got it.

I understand, well...I thought of seeing what's inside the microcontroller, which code - sketch, but don't know how to pull it out or if that's even possible. I think that I should pay some professional to fix it for me or give up entirely, I mean what else can I do?

Thank you very much for trying to help