About adjust arduino code with keypad.

Anyone can teach me about how to use keypad to adjust arduino code(uploaded).
My project(vending machine) has 6 slot for product with different prices.
i wish to use the keypad to change the prices without using arduino IDE.
EXAMPLE, my 1st product is RM0.10 and i want to change it to RM0.50 using keypad.

#include<Servo.h>
#include <Keypad.h>

volatile float coinsValue = 0.00;
const int coinInt = 1;
const byte ROWS = 3;
const byte COLS = 3;
Servo myservo1;
Servo myservo2;
int posi = 0;
int pos = 0;//analog servo speed
int door = 0;//for dc gear motor

float array [6] = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00};//use for multi-select or repeat select to purchase item(maximum 6 items in one purchase)

float Value1 = 0.00;
float Value2 = 0.00;
float Value3 = 0.00;
float Value4 = 0.00;
float Value5 = 0.00;
float Value6 = 0.00;

int motor1 = 0;
int motor2 = 0;

float total = 0.00;
boolean entered = false;

char keys [ROWS] [COLS] = {
  {'1', '2', '3',},
  {'4', '5', '6',},
  {'*', '0', '#',}
};

byte rowPins[] = { 13, 12, 11 };
byte colPins[] = { 10, 9, 8 };
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()

{ pinMode(7, OUTPUT);
  pinMode(6,OUTPUT);
  Serial.begin(9600);
  attachInterrupt(coinInt, coinInserted, RISING);
  myservo1.attach(4);
  myservo2.attach(5) ;
  myservo1.write(pos);
  myservo2.write(pos);
}

void coinInserted()
//The function that is called every time it receives a pulse
{
  coinsValue = coinsValue + 0.10;
  //1 pulse=RM0.10,2 pulse= RM0.20, 5 pulse=RM0.50(this is my country coins)
  Serial.println("Your already pay RM ");
  Serial.print(coinsValue);
}
void loop()

{

  char key = kpd.getKey();

  if (key) // Check for a valid key.
    if (key == '1') {
      if (posi < 6) {
        array[posi] = 0.10;//price for product
        posi = posi + 1;
        Serial.println("Value 1: ");
        Serial.println(key);
        Serial.println("");
      }
      motor1 = motor1 + 1;//will keep add 1 to motor1 if keep press key "1"(maximum 6 times)
    }
  if (key == '2') {
    if (posi < 6) {
      array[posi] = 0.20;
      posi = posi + 1;
      Serial.println("Value 2: ");
      Serial.println(key);
      Serial.println("");
    }
    motor2 = motor2 + 1;
  }
  if (key == '3') {
    if (posi < 6) {
      array[posi] = 0.30;
      posi = posi + 1;
      Serial.println("Value 3: ");
      Serial.println(key);
      Serial.println("");
    }
  }
  if (key == '4') {
    if (posi < 6) {
      array[posi] = 0.40;
      posi = posi + 1;
      Serial.println("Value 4: ");
      Serial.println(key);
      Serial.println("");
    }
  }
  if (key == '5') {
    if (posi < 6) {
      array[posi] = 0.50;
      posi = posi + 1;
      Serial.println("Value 5: ");
      Serial.println(key);
      Serial.println("");
    }
  }
  if (key == '6') {
    if (posi < 6) {
      array[posi] = 0.60;
      posi = posi + 1;
      Serial.println("Value 6: ");
      Serial.println(key);
      Serial.println("");
    }
  }//maximum 6 times to multi-select or repeat select with keypad "1" to "6"

  if (key == '#') {
    Value1 = array[0];
    Value2 = array[1];
    Value3 = array[2];
    Value4 = array[3];
    Value5 = array[4];
    Value6 = array[5];
    Serial.println("Total:");
    total = Value1 + Value2 + Value3 + Value4 + Value5 + Value6 ;
    Serial.println("You have to pay amount RM ");
    Serial.println(total);
    entered = true;
  }//use the "#" as enter and show the total value need to pay 
  if (coinsValue >= total && entered == true) {//put the coin to coin acceptor until value equal or over the total
    Serial.println("OKAY");
    delay(2000);
    if (motor1 != 0) {//when the motor1 not equal 1
      for (int x = 0; x < motor1; x++) {//if motor1=2 it will function 2 times 
        pos = 5;
        myservo1.write(pos);
        delay(3000);
        pos = 0;
        myservo1.write(pos);
        delay(3000);
        Serial.println("ggwp");
      }
      motor1 = 0;//reset the motor1
    }
    if (motor2 != 0) {
      for (int x = 0; x < motor2; x++) {
        pos = 5;
        myservo2.write(pos);
        delay(3000);
        pos = 0;
        myservo2.write(pos);
        delay(3000);
        Serial.println("ggwp1");
      }
      motor2 = 0;
    }
        if (motor3 != 0) {
      for (int x = 0; x < motor3; x++) {
        pos = 5;
        myservo3.write(pos);
        delay(3000);
        pos = 0;
        myservo3.write(pos);
        delay(3000);
        Serial.println("ggwp1");
      }
      motor3 = 0;
    }
        if (motor4!= 0) {
      for (int x = 0; x < motor4; x++) {
        pos = 5;
        myservo4.write(pos);
        delay(3000);
        pos = 0;
        myservo4.write(pos);
        delay(3000);
        Serial.println("ggwp1");
      }
      motor4 = 0;
    }
        if (motor5 != 0) {
      for (int x = 0; x < motor5; x++) {
        pos = 5;
        myservo5.write(pos);
        delay(3000);
        pos = 0;
        myservo5.write(pos);
        delay(3000);
        Serial.println("ggwp1");
      }
      motor5 = 0;
    }
        if (motor6 != 0) {
      for (int x = 0; x < motor6; x++) {
        pos = 5;
        myservo6.write(pos);
        delay(3000);
        pos = 0;
        myservo6.write(pos);
        delay(3000);
        Serial.println("ggwp1");
      }
      motor6 = 0;
    }
    door = 1;//for starting dc gear motor (automatic door)
    if(motor1==0 && motor2==0 && motor3==0 && motor4==0 && motor5==0 && motor6==0 && door==1){
      digitalWrite(7,HIGH);//dc gear motor forward
      analogWrite(6,5);//speed control
      delay(4000);
      digitalWrite(6,LOW);//dc gear motor stop
   Serial.println("qqq");
    }//it will start function after all product is drop from the slots
    posi = 0;//reset the value and waiting the next purchase
    Value1 = 0.00;//reset the value and waiting the next purchase
    Value2 = 0.00;//reset the value and waiting the next purchase
    Value3 = 0.00;//reset the value and waiting the next purchase
    Value4 = 0.00;//reset the value and waiting the next purchase
    Value5 = 0.00;//reset the value and waiting the next purchase
    Value6 = 0.00;//reset the value and waiting the next purchase
    total = 0.00;//reset the value and waiting the next purchase
    coinsValue = 0.00;//reset the value and waiting the next purchase
    for (int x = 0; x < 3; x++) {
      array[x] = 0;
    }
    entered = false;
  }
}

Here is my component list:
1.analog servo motor x6(as3103)
2.dc gear motorx1
3.keypad 3x4
4.coin acceptor(can accept 6 difference types)50sen=5 pulse,20sen =2 pulse,10sen =1 pulse
5.LCD displays 1602

Here is my vending machine(selling components) function:
1.Need to choose the product 1st(multi-select or repeat select)(maximum 6 times)
2.Press the “#” and it will show total cost
3.Put coin into coin acceptor until same value or over and it will show how much you pay
4.It will show “OKAY” and delay 2 sec servo motor will start function 1by1
5.Servo motor finish function, it will trigger dc gear motor open the door
6.Delay about 20sec, it will auto turn off the door
I wish to add the function “using keypad to change product value”

A program without comments or any detailed explanation of what the program is doing will take too long for us to work out.

Try supplying comments in the code and a full description of what it is doing.

Weedpharma

  Serial.println("Your already pay RM ");
  Serial.print(coinsValue);

In an interrupt service routine? NO!

What is coinsChange for? You initialize it, and change its value in the ISR, but never use it.

    if(motor1==0&&motor2==0&&motor3==0&&motor4==0&&motor5==0&&motor6==0&&door==1){

Youreallyneedtogetyourspacebarfixed.

Given the inherent inaccuracy that comes with float type variables, I would never dream of using them to keep up with money. I would keep up with money in an integer type variable and keep the value in cents rather than dollars. That will avoid some sneaky potential bugs down the road as this program gets bigger.

Never use float when you want exact values.

Delta_G:
Given the inherent inaccuracy that comes with float type variables, I would never dream of using them to keep up with money. I would keep up with money in an integer type variable and keep the value in cents rather than dollars. That will avoid some sneaky potential bugs down the road as this program gets bigger.

Never use float when you want exact values.

In my country, coin value have 3 types(50sen, 20sen, 10sen).
Below is the link about piggy bank,it can help me to avoid to using "float" or cant?

weedpharma:
A program without comments or any detailed explanation of what the program is doing will take too long for us to work out.

Try supplying comments in the code and a full description of what it is doing.

Weedpharma

Sry about that, i already edit it again.
Pls help me about "keypad to change the product value".
TY.

This kind of thing needs lots of user interaction. You need to give feedback to let them know which product they are editing and what the result is. I see you already have a lot of this in your program with the Serial.print() statements.

The best way to write this kind of interaction is to write the user manual first. You write in natural language which buttons to push and the expected response from the machine. Then it is easy to write the program to make that response.

PaulS:

  Serial.println("Your already pay RM ");

Serial.print(coinsValue);



In an interrupt service routine? NO!

What is coinsChange for? You initialize it, and change its value in the ISR, but never use it.



if(motor1==0&&motor2==0&&motor3==0&&motor4==0&&motor5==0&&motor6==0&&door==1){



Youreallyneedtogetyourspacebarfixed.

TY,i removed the coinsChange already.What happen about the code??I am sorry about my broken english.

  Serial.println("Your already pay RM ");
  Serial.print(coinsValue);

Serial depends on interrupts to function. In your ISR interrupts are disabled. If by some chance the outgoing serial buffer is full, your program will lock up in the ISR waiting for the print that's never going to happen. Never use Serial inside an ISR.

k1zzi:
In my country, coin value have 3 types(50sen, 20sen, 10sen).
Below is the link about piggy bank,it can help me to avoid to using “float” or cant?
http://pastebin.com/XS4SwwbU

50sen is 0.50RM? And in floating point you use 0.50?

Instead of float use int and the value will be 50.

If you always print sen then 150 is 150 sen but if you print RM then a little more is done like this:

// making the variables
int money = 150; // 150sen (cent is 1/100th, taken from a Roman word for 100)
int cents = 0; // used in printing the sen remaining

// inside the function you make to print money for human user to see:
Serial.print( money / 100 ); // takes care of RM, 99.99 would print 99 here.
Serial.print( F( “.” )); // then the decimal point
cents = money % 100; // % is modulo operator, it returns the remainder of the divide
if ( cents < 10 )
{
Serial.print( F( “0” )); // if no 10’s of cents, print a 0, otherwise 1.05 RM would show as 1.5.
}
Serial.print( cents );
Serial.print( F( " RM" ));

If no coin is ever anything but 10’s of sen then you will never have (cents < 10), no need for that if().
But if you cut that out, leave a comment that says the code only handles values in 10’s.

GoForSmoke:
50sen is 0.50RM? And in floating point you use 0.50?

Instead of float use int and the value will be 50.

If you always print sen then 150 is 150 sen but if you print RM then a little more is done like this:

// making the variables
int money = 150; // 150sen (cent is 1/100th, taken from a Roman word for 100)
int cents = 0; // used in printing the sen remaining

// inside the function you make to print money for human user to see:
Serial.print( money / 100 ); // takes care of RM, 99.99 would print 99 here.
Serial.print( F( “.” )); // then the decimal point
cents = money % 100; // % is modulo operator, it returns the remainder of the divide
if ( cents < 10 )
{
Serial.print( F( “0” )); // if no 10’s of cents, print a 0, otherwise 1.05 RM would show as 1.5.
}
Serial.print( cents );
Serial.print( F( " RM" ));

If no coin is ever anything but 10’s of sen then you will never have (cents < 10), no need for that if().
But if you cut that out, leave a comment that says the code only handles values in 10’s.

How i change the “RM” to front??EXAMPLE:RM0.50

const int coinInt = 0;
int coinsChange = 0;
int money = 0;
int cents = 0;
void setup() {
  Serial.begin(9600);
  attachInterrupt(coinInt, coinInserted, RISING);
}
void coinInserted()
{
  money = money + 10;
  coinsChange = 1;
}
void loop()
{
  if (coinsChange == 1)
  {
    coinsChange = 0;
    Serial.print( money / 100 );
    Serial.print( F( "." ));
    cents = money % 100;
    if ( cents < 10 )
    {
      Serial.print( F( "0" ));
    }
    Serial.print( cents );
    Serial.print( F( " RM" ));
  }
}

k1zzi:
How i change the “RM” to front??

EXAMPLE:RM0.50

const int coinInt = 0;

int coinsChange = 0;
int money = 0;
int cents = 0;
void setup() {
  Serial.begin(9600);
  attachInterrupt(coinInt, coinInserted, RISING);
}
void coinInserted()
{
  money = money + 10;
  coinsChange = 1;
}
void loop()
{
  if (coinsChange == 1)
  {
    coinsChange = 0;
    Serial.print( money / 100 );
    Serial.print( F( " RM" ));      // then print RM first
    Serial.print( F( “.” ));
    cents = money % 100;
    if ( cents < 10 )
    {
      Serial.print( F( “0” ));
    }
    Serial.print( cents );
//    Serial.print( F( " RM" ));    // instead of print RM last
  }
}

But you want to make the part that shows the money into a separate function that can be used when you show the prices if you do that too.

const int coinInt = 0;
int coinsChange = 0;
int money = 0;
int cents = 0;

void setup() {
  Serial.begin(9600);
  attachInterrupt(coinInt, coinInserted, RISING);
}

void coinInserted()
{
  money = money + 10; 
  coinsChange = 1;
}

void showMeTheMoney( int howMuch ) 
{
  Serial.print( howMuch / 100 );
  Serial.print( F( " RM" ));       // print RM first
  Serial.print( F( "." ));

  cents = howMuch % 100;
  if ( cents < 10 )
  {
    Serial.print( F( "0" ));
  }
  Serial.print( cents );
}

void loop()
{
  if (coinsChange == 1)
  {
    coinsChange = 0;
    showMeTheMoney( money );
  }
}

You want to be able to change the prices of items without downloading new code, those are DATA not CODE.

One place to keep the prices is in the on-chip EEPROM of your Arduino/AVR chip. There is an EEPROM library and some learning curve you can get over by messing with the library examples in your IDE.

What you write to EEPROM will stay when power is off. The sketch will read the values stored there as part of setup().

https://www.arduino.cc/en/Reference/EEPROM

EEPROM can change during run time but only expect to 100,000 times. At human entering data speed that will take a very long time even trying hard while never sleeping. Code can wear EEPROM out quickly, if EEPROM is used like RAM.

GoForSmoke:
But you want to make the part that shows the money into a separate function that can be used when you show the prices if you do that too.

const int coinInt = 0;

int coinsChange = 0;
int money = 0;
int cents = 0;

void setup() {
  Serial.begin(9600);
  attachInterrupt(coinInt, coinInserted, RISING);
}

void coinInserted()
{
  money = money + 10;
  coinsChange = 1;
}

void showMeTheMoney( int howMuch )
{
  Serial.print( howMuch / 100 );
  Serial.print( F( " RM" ));      // print RM first
  Serial.print( F( “.” ));

cents = howMuch % 100;
  if ( cents < 10 )
  {
    Serial.print( F( “0” ));
  }
  Serial.print( cents );
}

void loop()
{
  if (coinsChange == 1)
  {
    coinsChange = 0;
    showMeTheMoney( money );
  }
}





You want to be able to change the prices of items without downloading new code, those are DATA not CODE.

One place to keep the prices is in the on-chip EEPROM of your Arduino/AVR chip. There is an EEPROM library and some learning curve you can get over by messing with the library examples in your IDE.

What you write to EEPROM will stay when power is off. The sketch will read the values stored there as part of setup().

https://www.arduino.cc/en/Reference/EEPROM

EEPROM can change during run time but only expect to 100,000 times. At human entering data speed that will take a very long time even trying hard while never sleeping. Code can wear EEPROM out quickly, if EEPROM is used like RAM.

TY for reply.Can help me solve this problem??
I change the float to int already. at the key “1” to “6” product price have some problem,i change the 0.10, 0.20, 0.30, 0.40, 0.50, 0.60 to 10, 20, 30, 40, 50, 60.When i using key"#" to calculate total price
it show me RM100 not RM1.00(dot is missing). What should i do??

#include<Servo.h>
#include <Keypad.h>

const int coinInt = 1;
int money = 0;
int cents = 0;
const byte ROWS = 3;
const byte COLS = 3;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
Servo myservo5;
Servo myservo6;
int posi = 0;
int pos = 0;
int door = 0;

int array [10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int Value1 = 0;
int Value2 = 0;
int Value3 = 0;
int Value4 = 0;
int Value5 = 0;
int Value6 = 0;
int motor1 = 0;
int motor2 = 0;
int motor3 = 0;
int motor4 = 0;
int motor5 = 0;
int motor6 = 0;
int total = 0;
boolean entered = false;

char keys [ROWS] [COLS] = {
  {'1', '2', '3',},
  {'4', '5', '6',},
  {'*', '0', '#',}
};

byte rowPins[] = { 13, 12, 11 };
byte colPins[] = { 10, 9, 8 };
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()

{ pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  Serial.begin(9600);
  attachInterrupt(coinInt, coinInserted, RISING);
  myservo1.attach(4);
  myservo2.attach(5);
  myservo1.write(pos);
  myservo2.write(pos);
}

void coinInserted()
{
  money = money + 10;
  showMeTheMoney( money );
}

void showMeTheMoney( int howMuch ) 
{
  Serial.print( howMuch / 100 );
  Serial.print( F( " RM" ));       // print RM first
  Serial.print( F( "." ));

  cents = howMuch % 100;
  if ( cents < 10 )
  {
    Serial.print( F( "0" ));
  }
  Serial.print( cents );
}
void loop()
{
  char key = kpd.getKey();
  if (key) 
    if (key == '1') {
      if (posi < 6) {
        array[posi] = 10;//1st prodct price
        posi = posi + 1;
        Serial.println("Value 1: ");
        Serial.println(key);
        Serial.println("");
      }
      motor1 = motor1 + 1;
    }
  if (key == '2') {
    if (posi < 6) {
      array[posi] = 20;//2nd product price
      posi = posi + 1;
      Serial.println("Value 2: ");
      Serial.println(key);
      Serial.println("");
    }
    motor2 = motor2 + 1;
  }
  if (key == '3') {
    if (posi < 6) {
      array[posi] = 30;//3rd product price
      posi = posi + 1;
      Serial.println("Value 3: ");
      Serial.println(key);
      Serial.println("");
    }
  }
  if (key == '4') {
    if (posi < 6) {
      array[posi] = 40;//4th product price
      posi = posi + 1;
      Serial.println("Value 4: ");
      Serial.println(key);
      Serial.println("");
    }
  }
  if (key == '5') {
    if (posi < 6) {
      array[posi] = 50;//5th product price
      posi = posi + 1;
      Serial.println("Value 5: ");
      Serial.println(key);
      Serial.println("");
    }
  }
  if (key == '6') {
    if (posi < 6) {
      array[posi] = 60;//6th product price
      posi = posi + 1;
      Serial.println("Value 6: ");
      Serial.println(key);
      Serial.println("");
    }
  }
  if (key == '#') {//enter key and total price
    Value1 = array[0];
    Value2 = array[1];
    Value3 = array[2];
    Value4 = array[3];
    Value5 = array[4];
    Value6 = array[5];
    Serial.println("Total:");
    total = Value1 + Value2 + Value3 + Value4 + Value5 + Value6 ;
    Serial.println("TOTAL: RM ");// at here, it got some problem. the TOTAL show be RM 1.00 it keep show me RM100 without "."
    Serial.println(total);
    entered = true;
  }
  if (money >= total && entered == true) {
    Serial.println("OKAY");
    delay(2000);
    if (motor1 != 0) {
      for (int x = 0; x < motor1; x++) {
        pos = 5;
        myservo1.write(pos);
        delay(3000);
        pos = 0;
        myservo1.write(pos);
        delay(3000);
        Serial.println("1st");
      }
      motor1 = 0;
    }
    if (motor2 != 0) {
      for (int x = 0; x < motor2; x++) {
        pos = 5;
        myservo2.write(pos);
        delay(3000);
        pos = 0;
        myservo2.write(pos);
        delay(3000);
        Serial.println("2nd");
      }
      motor2 = 0;
    }
    if (motor3 != 0) {
      for (int x = 0; x < motor3; x++) {
        pos = 5;
        myservo3.write(pos);
        delay(3000);
        pos = 0;
        myservo3.write(pos);
        delay(3000);
        Serial.println("3rd");
      }
      motor3 = 0;
    }
    if (motor4 != 0) {
      for (int x = 0; x < motor4; x++) {
        pos = 5;
        myservo4.write(pos);
        delay(3000);
        pos = 0;
        myservo4.write(pos);
        delay(3000);
        Serial.println("4th");
      }
      motor4 = 0;
    }
    if (motor5 != 0) {
      for (int x = 0; x < motor5; x++) {
        pos = 5;
        myservo5.write(pos);
        delay(3000);
        pos = 0;
        myservo5.write(pos);
        delay(3000);
        Serial.println("5th");
      }
      motor5 = 0;
    }
    if (motor6 != 0) {
      for (int x = 0; x < motor6; x++) {
        pos = 5;
        myservo6.write(pos);
        delay(3000);
        pos = 0;
        myservo6.write(pos);
        delay(3000);
        Serial.println("6th");
      }
      motor6 = 0;
    }
    door = 1;
    if (motor1 == 0 && motor2 == 0 && motor3 == 0 && motor4 == 0 && motor5 == 0 && motor6 == 0 && door == 1) {
      Serial.println("door open");
      digitalWrite(7, HIGH);
      analogWrite(6,50);
      delay(4000);
      digitalWrite(6, LOW);
      delay(4000);
      digitalWrite(7, LOW);
      analogWrite(6,50);
      delay(4000);
      digitalWrite(6, LOW);
      Serial.println("door close");
    }
    door =0;
    posi = 0;
    Value1 = 0;
    Value2 = 0;
    Value3 = 0;
    Value4 = 0;
    Value5 = 0;
    Value6 = 0;
    total = 0;
    money = 0;
    for (int x = 0; x < 3; x++) {
      array[x] = 0;
    }
    entered = false;
  }
}

Yes, you are now keeping up with money in cents. So it is showing you the number in cents. If you want the number back into dollars (I'm using American money for example because I don't know yours but same concept) then you can add the decimal when you print it out.

int totalMoneyInCents = 678;  // 6 dollars 78 cents

Serial.print("I have this much money in cents  ");
Serial.println(totalMoneyInCents);

Serial.print("I have this much in dollars  ");
Serial.print(totalMoneyInCents / 100);
Serial.print(".");
Serial.println(totalMoneyInCents % 100);

Or you can use sprintf to do something similar if you want to assemble that into a string.

char buf[10];

sprintf(buf, "%d.%02d" , totalMoneyInCents / 100, totalMoneyInCents % 100);
Serial.println(buf);

TY for reply.Can help me solve this problem??
I change the float to int already. at the key “1” to “6” product price have some problem,i change the 0.10, 0.20, 0.30, 0.40, 0.50, 0.60 to 10, 20, 30, 40, 50, 60.When i using key"#" to calculate total price
it show me RM100 not RM1.00(dot is missing). What should i do??

I think you should look more carefully at the code and what it prints.
I prints the number of RM then it prints the letters RM then it prints . then it prints cents.
The fix is insanely simple, move the line that prints the letters RM to before the line that prints the value.
The order of things printed in showMeTheMoney() is the order of the Serial.print() lines.

void showMeTheMoney( int howMuch )
{
  Serial.print( F( "RM" ));           // print RM first
  Serial.print( howMuch / 100 );
//  Serial.print( F( " RM" ));       // wrong line, my bad, fix is 2 lines above
  Serial.print( F( "." ));

  cents = howMuch % 100;
  if ( cents < 10 )
  {
    Serial.print( F( "0" ));
  }
  Serial.print( cents );
}

You also have at least one place where you simply print the value instead of using showMeTheMoney()

    Serial.println("TOTAL: RM ");// at here, it got some problem. the TOTAL show be RM 1.00 it keep show me RM100 without "."
    Serial.println(total);            // <<=== this will not print the decimal point

Your code should look more like this, which does compile but is NOT debugged.

#include<Servo.h>
#include <Keypad.h>

const int coinInt = 1;
int money = 0;
int cents = 0;

int posi = 0;
int pos = 0;
int door = 0;

byte idx; // use as index into
int array[ 10 ]; // by default, all are 0 at start
Servo myservo[ 6 ]; // servos now in an array
int Value[ 6 ]; // by default all are = 0
int motor[ 6 ];
byte motorsRunning;

int total = 0;

boolean entered = false;

const byte ROWS = 3;
const byte COLS = 3;

char keys [ROWS] [COLS] = {
  {'1', '2', '3',},
  {'4', '5', '6',},
  {'*', '0', '#',}
};

byte rowPins[] = { 13, 12, 11 };
byte colPins[] = { 10, 9, 8 };

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  Serial.begin(9600);  // why is this less than 115200?

  attachInterrupt(coinInt, coinInserted, RISING);

  myservo[ 0 ].attach(4);
  myservo[ 1 ].attach(5);
  myservo[ 0 ].write(pos);
  myservo[ 1 ].write(pos);
}

void coinInserted()
{
  money = money + 10;
  showMeTheMoney( money );
}

void showMeTheMoney( int howMuch )
{
  Serial.print( F( "RM" ));           // print RM first
  Serial.print( howMuch / 100 );
  Serial.print( F( "." ));

  cents = howMuch % 100;
  if ( cents < 10 )
  {
    Serial.print( F( "0" ));
  }
  Serial.print( cents );
}

void loop()
{
  char key = kpd.getKey();
  if (key)
  {
    switch ( key )
    {
      case '1' :
        {
          if (posi < 6)
          {
            array[posi] = 10;//1st prodct price
            posi = posi + 1;
            Serial.println("Value 1: ");
            Serial.println(key);
            Serial.println("");
          }
          motor[ 0 ] += 1;
          motorsRunning = 1;
        }
        break;

      case '2' :
        {
          if (posi < 6)
          {
            array[posi] = 20;//2nd product price
            posi = posi + 1;
            Serial.println("Value 2: ");
            Serial.println(key);
            Serial.println("");
          }
          motor[ 1 ] += 1;
          motorsRunning = 1;
        }
        break;

      case '3' :
        {
          if (posi < 6)
          {
            array[posi] = 30;//3rd product price
            posi = posi + 1;
            Serial.println("Value 3: ");
            Serial.println(key);
            Serial.println("");
          }
        }
        break;

      case '4' :
        {
          if (posi < 6)
          {
            array[posi] = 40;//4th product price
            posi = posi + 1;
            Serial.println("Value 4: ");
            Serial.println(key);
            Serial.println("");
          }
        }
        break;

      case '5' :
        {
          if (posi < 6)
          {
            array[posi] = 50;//5th product price
            posi = posi + 1;
            Serial.println("Value 5: ");
            Serial.println(key);
            Serial.println("");
          }
        }
        break;

      case '6' :
        {
          if (posi < 6)
          {
            array[posi] = 60;//6th product price
            posi = posi + 1;
            Serial.println("Value 6: ");
            Serial.println(key);
            Serial.println("");
          }
        }
        break;

      case '#' : //enter key and total price
        {
          total = 0;
          for ( idx = 0; idx < 6; idx++ )
          {
            Value[ idx ] = array[ idx ];
            total += Value[ idx ];
          }

          Serial.println("Total:");
          Serial.println("TOTAL: RM ");// at here, it got some problem. the TOTAL show be RM 1.00 it keep show me RM100 without "."
          showMeTheMoney( total );
          entered = true;
        }
    }


    if (money >= total && entered == true)
    {

      Serial.println("OKAY");
      delay(2000);

      for ( idx = 0; idx < 6; idx++ )
      {
        if (motor[ idx ] != 0)
        {
          for ( byte x = 0; x < motor[ idx ]; x++ )
          {
            pos = 5;
            myservo[ idx ].write(pos);
            delay(3000);
            pos = 0;
            myservo[ idx ].write(pos);
            delay(3000);
            Serial.print( idx + 1 );
            Serial.println(": ");
          }
          motor[ idx ] = 0;
        }
      }

      door = 1;
//    if (( motorsRunning == 0 ) && ( door == 1 )) // silly, door just got set to 1
      if ( motorsRunning == 0 )
      {
        Serial.println("door open");
        digitalWrite(7, HIGH);
        analogWrite(6, 50);
        delay(4000);
        digitalWrite(6, LOW);
        delay(4000);
        digitalWrite(7, LOW);
        analogWrite(6, 50);
        delay(4000);
        digitalWrite(6, LOW);
        Serial.println("door close");
      }

      motorsRunning = 0;
      door = 0;
      posi = 0;

      for ( idx = 0; idx < 6; idx++ )
      {
        Value[ idx ] = 0;
      }
      total = 0;
      money = 0;
      for ( byte x = 0; x < 3; x++ ) // why only clear the 1st 3 elements?
      {
        array[x] = 0;
      }
      entered = false;

    }
  }
}

Please look for comments that you did not put in since some ask you WHY type questions

Sorry for my shortness of patience but my leg got hurt and I have very little patience left.
You might have to get others to help but the above is shorter and more readable.

Do what everyone else does and use a password or very specific button combination to get to a submenu with all the prices.

GoForSmoke:
Your code should look more like this, which does compile but is NOT debugged.

#include<Servo.h>

#include <Keypad.h>

const int coinInt = 1;
int money = 0;
int cents = 0;

int posi = 0;
int pos = 0;
int door = 0;

byte idx; // use as index into
int array[ 10 ]; // by default, all are 0 at start
Servo myservo[ 6 ]; // servos now in an array
int Value[ 6 ]; // by default all are = 0
int motor[ 6 ];
byte motorsRunning;

int total = 0;

boolean entered = false;

const byte ROWS = 3;
const byte COLS = 3;

char keys [ROWS] [COLS] = {
  {‘1’, ‘2’, ‘3’,},
  {‘4’, ‘5’, ‘6’,},
  {’*’, ‘0’, ‘#’,}
};

byte rowPins = { 13, 12, 11 };
byte colPins = { 10, 9, 8 };

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup()
{
  pinMode(7, OUTPUT);
  pinMode(6, OUTPUT);
  Serial.begin(9600);  // why is this less than 115200?

attachInterrupt(coinInt, coinInserted, RISING);

myservo[ 0 ].attach(4);
  myservo[ 1 ].attach(5);
  myservo[ 0 ].write(pos);
  myservo[ 1 ].write(pos);
}

void coinInserted()
{
  money = money + 10;
  showMeTheMoney( money );
}

void showMeTheMoney( int howMuch )
{
  Serial.print( F( “RM” ));          // print RM first
  Serial.print( howMuch / 100 );
  Serial.print( F( “.” ));

cents = howMuch % 100;
  if ( cents < 10 )
  {
    Serial.print( F( “0” ));
  }
  Serial.print( cents );
}

void loop()
{
  char key = kpd.getKey();
  if (key)
  {
    switch ( key )
    {
      case ‘1’ :
        {
          if (posi < 6)
          {
            array[posi] = 10;//1st prodct price
            posi = posi + 1;
            Serial.println(“Value 1: “);
            Serial.println(key);
            Serial.println(””);
          }
          motor[ 0 ] += 1;
          motorsRunning = 1;
        }
        break;

case ‘2’ :
        {
          if (posi < 6)
          {
            array[posi] = 20;//2nd product price
            posi = posi + 1;
            Serial.println(“Value 2: “);
            Serial.println(key);
            Serial.println(””);
          }
          motor[ 1 ] += 1;
          motorsRunning = 1;
        }
        break;

case ‘3’ :
        {
          if (posi < 6)
          {
            array[posi] = 30;//3rd product price
            posi = posi + 1;
            Serial.println(“Value 3: “);
            Serial.println(key);
            Serial.println(””);
          }
        }
        break;

case ‘4’ :
        {
          if (posi < 6)
          {
            array[posi] = 40;//4th product price
            posi = posi + 1;
            Serial.println(“Value 4: “);
            Serial.println(key);
            Serial.println(””);
          }
        }
        break;

case ‘5’ :
        {
          if (posi < 6)
          {
            array[posi] = 50;//5th product price
            posi = posi + 1;
            Serial.println(“Value 5: “);
            Serial.println(key);
            Serial.println(””);
          }
        }
        break;

case ‘6’ :
        {
          if (posi < 6)
          {
            array[posi] = 60;//6th product price
            posi = posi + 1;
            Serial.println(“Value 6: “);
            Serial.println(key);
            Serial.println(””);
          }
        }
        break;

case ‘#’ : //enter key and total price
        {
          total = 0;
          for ( idx = 0; idx < 6; idx++ )
          {
            Value[ idx ] = array[ idx ];
            total += Value[ idx ];
          }

Serial.println(“Total:”);
          Serial.println("TOTAL: RM ");// at here, it got some problem. the TOTAL show be RM 1.00 it keep show me RM100 without “.”
          showMeTheMoney( total );
          entered = true;
        }
    }

if (money >= total && entered == true)
    {

Serial.println(“OKAY”);
      delay(2000);

for ( idx = 0; idx < 6; idx++ )
      {
        if (motor[ idx ] != 0)
        {
          for ( byte x = 0; x < motor[ idx ]; x++ )
          {
            pos = 5;
            myservo[ idx ].write(pos);
            delay(3000);
            pos = 0;
            myservo[ idx ].write(pos);
            delay(3000);
            Serial.print( idx + 1 );
            Serial.println(": ");
          }
          motor[ idx ] = 0;
        }
      }

door = 1;
//    if (( motorsRunning == 0 ) && ( door == 1 )) // silly, door just got set to 1
      if ( motorsRunning == 0 )
      {
        Serial.println(“door open”);
        digitalWrite(7, HIGH);
        analogWrite(6, 50);
        delay(4000);
        digitalWrite(6, LOW);
        delay(4000);
        digitalWrite(7, LOW);
        analogWrite(6, 50);
        delay(4000);
        digitalWrite(6, LOW);
        Serial.println(“door close”);
      }

motorsRunning = 0;
      door = 0;
      posi = 0;

for ( idx = 0; idx < 6; idx++ )
      {
        Value[ idx ] = 0;
      }
      total = 0;
      money = 0;
      for ( byte x = 0; x < 3; x++ ) // why only clear the 1st 3 elements?
      {
        array = 0;
      }
      entered = false;

}
  }
}




Please look for comments that you did not put in since some ask you WHY type questions

Sorry for my shortness of patience but my leg got hurt and I have very little patience left.
You might have to get others to help but the above is shorter and more readable.

TY and hope u fast recovery(and forgive me about my broken english)

My hip popped back into the socket last night. Muscles sore but I hope not for long.

That code should be rearranged so that the coin input can happen any time, nobody takes it well when they lose money in a machine. All the delays need to be replaced with time-driven code which will take some doing. The code that should be will be like 3 different projects that work together. But you can test/debug procedures on what you've got now.

Any commands that you don't know yet like the switch-case statement, look them up in the main Arduino site Reference page.