i need help about arduino code for combine LCD,COIN ACCEPTOR, CONTINUOUS ROTATION SERVO & KEYPAD to build a vending machine~~
my vending machine function is:
1.choose the product with keypad(can choose multi-product in one times)
2."*"use as cancel the order and "#" use as confirm order
3.LCD will display the total cost of product
4.insert coin to coin acceptor untill reach the total cost
5.after reach the total cost,servo will start function 1 by 1
k1zzi:
i need help about arduino code for combine LCD,COIN ACCEPTOR, CONTINUOUS ROTATION SERVO & KEYPAD to build a vending machine~~
my vending machine function is:
1.choose the product with keypad(can choose multi-product in one times)
2."*"use as cancel the order and "#" use as confirm order
3.LCD will display the total cost of product
4.insert coin to coin acceptor untill reach the total cost
5.after reach the total cost,servo will start function 1 by 1
ty for helping~~~
Which part are you having a problem with? More info would help.
Or do you want someone to write it for you?
k1zzi:
sorry about that, i cant pay money to u. My pocket almost empty...
my component list
1.LCD 1602C
2.SERVO AS3103
3.KEYPAD 3X4
4.COIN ACCEPTOR
I don't want to do it anyway. I'm busy on my own project. I just thought that if you mentioned how much you were prepared to pay, it might encourage someone to do it for you.
So, you're making a product that will make money for you, but you want someone to write the whole program for free? That's not very fair.
#include <Keypad.h>
#include<Servo.h>
Servo myservo;
int pos = 0;
const byte ROWS = 4;
const byte COLS = 3;
char keys [ROWS] [COLS] = {
{'1', '2', '3',},
{'4', '5', '6',},
{'7', '8', '9',},
{'*', '0', '#',}
};
byte rowPins[] = { 9, 8, 7, 6 };
byte colPins[] = { 12, 11, 10 };
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define ledpin 13
void setup()
{
myservo.attach(2);
myservo.write(pos);
Serial.begin(9600);
}
void loop()
{
char key = kpd.getKey();
if (key) // Check for a valid key.
{
switch (key)
{
case '1':
Serial.println(key);
pos = 0;
myservo.write(pos);
break;
case '2':
Serial.println(key);
pos = 5;
myservo.write(pos);
delay(1375);
pos = 0;
myservo.write(pos);
break;
case '3':
Serial.println(key);
break;
case '4':
Serial.println(key);
break;
case '5':
Serial.println(key);
break;
case '6':
Serial.println(key);
break;
case '7':
Serial.println(key);
break;
case '8':
Serial.println(key);
break;
case '9':
Serial.println(key);
break;
case '0':
Serial.println(key);
break;
case '*':
Serial.println(key);
break;
case '#':
Serial.println(key);
break;
}
}
}
i only know use the case "1" start the servo and case"2" stop the servo
i dont know where to start to write the 1st function, pls give me some suggestion
What do you want to use the keypad for? Does each key represent a different product?
...R
i use the keypad(1-6) to select 6 different product and the"*"as cancel order "#"as confirm order.After confirm, LCD will display total cost of product and "pls insert coin" .Insert coin to coin acceptor as same value as LCD show, servo will start function 1 by 1.
Before i post this topic, i have discuss with my friend to solve it.
He say need to use float A=(product value) to avoid servo move before coin insert to coin acceptor and float B=(A) for after coin insert same with the product value and trigger the servo function.
May i know some code about analog signal continuous rotation servor how to control angle.
k1zzi:
he say need to use float A=(product value) to avoid servo move before coin insert to coin acceptor and float B=(A) for after coin insert untill with the same value.show me some examples,ty.
Don't use float values for money. Just use pennies (or cents) because floats aren't precise enough. For displaying to the user you can put a decimal point in the display to show pennies as £.pp
Then you can easily have an IF like this
if (inputPennies >= pricePennies) {
// move servo to dispense item
}
Robin2:
Don't use float values for money. Just use pennies (or cents) because floats aren't precise enough. For displaying to the user you can put a decimal point in the display to show pennies as £.pp
i dont know how to change the "volatile float coinValue=0.00"
volatile int coinValue = 0;
I think you would benefit from working carefully through several of the example programs that come with the Arduino IDE and a bit of self-study into the C/C++ programming language.
I think you would benefit from working carefully through several of the example programs that come with the Arduino IDE and a bit of self-study into the C/C++ programming language.
k1zzi:
can teach me about multi-select products by using keypad 3x4 and show the total value after finish select??
What does the code you have posted actually do when you run it?
What would you like it to do?
Your question is like an invitation to write the program for you, and I am not going to do that. If there are particular parts of your code that you can't get working I will try to help.