that IS the same exact unit...
i agree, i see no issue programming the acceptor at all..it's getting the arduino and lcd to work when a coin is detected by pulse as you mentioned and that's going to be my downfall.
that IS the same exact unit...
i agree, i see no issue programming the acceptor at all..it's getting the arduino and lcd to work when a coin is detected by pulse as you mentioned and that's going to be my downfall.
lastchancename:
I hope you’re making notes, i want to see some code in the next few days!
been attempting since the start.. #5 & #7
here's what i've been working on since:
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & config exapander chip
// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;
// Coin acceptor
const int coins = 2; // white or grey wire from machine
// Buttons - (connect with 10k resistor each)
const int menuButton = 3; // will change the lcd screen to show coin counts
const int resetButton = 4; // this will reset ALL counts - no turning back
// Passive speaker - (optional)
//int speaker = 5; // passive speaker, not sure if i want a speaker for this project yet..
// RGB LEDS - (optional), use 3x 330k resistors for each, can be adjusted
// i wont be using any at this time
// int RGBled1 = 6;
// int RGBled2 = 7;
// int RGBled3 = 8;
// int RGBled4 = 9;
//lcd pins 20 & 21 - (sda & scl)
byte coins;
byte Pennies(); //how many pennies
byte Nickles(); //how many nickles
byte Dimes(); //how many dimes
byte Quarters(); //how many quarters
byte HalfDollars(); // how many half dollars
byte DollarCoins(); // how many dollar coins
byte Savings(); //used for total calculation of amount of money saved - show dollar format including commas where needed
void setup()
{
int status;
status = lcd.begin(LCD_COLS, LCD_ROWS);
// Print a message to the LCD
// basically the initial setup of how i want it
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" xxxxxxxxxx xxx "); // 1st row - PRIVATE
lcd.setCursor (0, 1);
lcd.print(" xxxxxxx xxxxxxxxx "); // 2nd row - PRIVATE
lcd.setCursor(0, 2);
lcd.print(" xxxxxxxxx xxxx "); // 3rd row - PRIVATE
lcd.setCursor(0, 3);
lcd.print("xxx xxxxxx xxxxxxxxx"); // 4th row - PRIVATE
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Quarters: 0"); //text to the left side and count right side if possible, use commas
lcd.setCursor(0, 1);
lcd.print("Dimes: 0"); //text to the left side and count right side if possible, use commas
lcd.setCursor(0, 2);
lcd.print("Nickles: 0"); //text to the left side and count right side if possible, use commas
lcd.setCursor(0, 3);
lcd.print("Pennies: 0"); //text to the left side and count right side if possible, use commas
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Halves: 0"); //text to the left side and count right side if possible, use commas
lcd.setCursor(0, 1);
lcd.print("Dollar: 0"); //text to the left side and count right side if possible, use commas
lcd.setCursor(0, 2);
lcd.print(" Total Coins: "); //text to the right side and count left side if possible, use commas
lcd.setCursor(0, 3);
lcd.print("0"); //count right side if possible, use commas
delay(3000);
lcd.clear();
// now go to main INSERT COINS screen
}
void loop()
{
// blinking text until a coin is inserted - (then show another screed.. "AWESOME! Savings: $1,000.00 EXAMPLE)
lcd.setCursor(0, 1);
lcd.print(" INSERT ");
lcd.setCursor(0, 2);
lcd.print(" CHANGE "); // wanted to say coins, but for visual evenness, same amt of txt used
delay(500);
lcd.clear();
delay(500);
}
now what i need help with is counting pulses so it adds to savings everytime i insert a coin.. basically i want it to work..
ok, time for someone to throw some example code in... cause i went as far as i could with this atm..
Let’s introduce another new concept... State Machines
Again, there are plenty of tutorials and guides.
The principle is simple.
Your coin handler can only be in ONE (finite) state at a time...
Initialising, Waiting for a coin, displaying a total, menu, power-fail... etc.
Based on what’s happening, you would step through, or jump between states.
Based on the current state, you - do, or display something that you need done.
HOWEVER
PaulMurrayCbr observed...
...in the end it will output a pulse when ‘enough’ coins have been inserted to match your desired total.
That is - the device itself does all the work of adding up the values of different types of coins.
Which makes the OP requirements incompatible with this device.
If there is no specific output that indicates each individual coin denomination, the aim of counting individual values is not going to happen with this mech.
The best the display can do is simply increment - each time the pre-programmed value has been reached,
so yer trying to say that there is absolutely no way to store the values of each coin? i find that hard to believe. if the value can increment then surely it can be stored every time a coin is inserted, hence can be displayed when you press the button to change the lcd screen. hence why i hesitated using the eeprom because of the many writes.
right now i just need the code to display and increment every time a coin is inserted..
Yer?
Features
Intelligent CPU software control, and high accuracy
Self-programming without PC
Programmable 1 ~ 6 different kinds of coins / token
Pulse output
Automatic self-test for error
it has an output.. PULSE
so, my q is can somebody please write some code that when i insert a coin it adds and displays on the lcd.. after that then we can save by pulse count, but right now i'd like the most important part of the code so i see the total incrementing on the lcd.
NO - I made a mistake -
I had a look at the video guide back at the top.
So it's all good news. (It may need minor tweaking for timing)
Start by testing the state of the COIN pin
So you can see what's happening - display it on the serial monitor.
Next do the same with the PULSE pin
Add the coin denomination for each individual coin.
When the PULSES have finished - process the coin total.
Use the next COIN state to reset/enable the counter.
i know how to setup the machine.. it's the arduino code i need help with...
i need more code in here, so when i insert the coins - the lcd shows the savings and it increments every time a coin is inserted.. i assume something like post #7??? i don't know
void loop()
{
lcd.setCursor(0, 1);
lcd.print(" INSERT ");
lcd.setCursor(0, 2);
lcd.print(" CHANGE ");
delay(500);
lcd.clear();
delay(500);
}
?
I don’t see anywhere that you’re trying to test the COIN input, or accumulating pulses from the PUKSE pin.
That’s an important starting point.
Reposting your first screen display isn’t going to get far.
How about declaring your pins, like you started to do in post #5
Maybe decide on your pulse counting strategy.
Are you going to use a state machine within loop()
All these suggestions will make sense when the mech arrives, but don’t need the mech for you to move forward.
“”know how to setup the machine.. it's the arduino code i need help with...””
I for one have no intention of helping you setup the machine. That’s covered in spades within the documentation.
Learn how to count PULSES, them how to reset that counter when another input is triggered (COIN).
Everything else is icing on the cake. Don’t try to run until you can walk!
I'm curious if 'COIN' acts as a gate to tell you when to start / stop counting pulses. Or, it's only a start signal and you have to rely on timing to know when all the pulses have arrived.
Guess OP will need to put an O'scope on the lines when hardware arrives.
Yeah, i was wondering as well, but that’s a tiny question that i hinted at a few posts ago.
I suspect/hope it’s just a simple ‘enable’ that says watch the count while i’m true.
Otherwise OP will need to count until a time-out on the pulses.
ok, between the following vids:
neither one match - different coding.. and me being inexperienced coder for arduino.. not fun or easy to make a conscience decision on how to go about coding what i want.. here is what i cam up with so far and i honestly cannot go any further in coding at this time because nothing is clear no coding snippets have been given.. so, i stop here until someone wants to show me in coding how one is to go about this.. here's a reason for a complete tutorial to be made..
everybody talks to everyone as if they are just as experienced as they are, not people like me are not...
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & config exapander chip
// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;
// attach coin wire to digital 2 - WHITE/pulses
#define COIN 2
int coins;
// Buttons - (connect with 10k resistor each)
const int menuButton = 3; // will change the lcd screen to show coin counts
const int resetButton = 4; // this will reset ALL counts - no turning back
// Passive speaker - (optional)
//int speaker = 5; // passive speaker, not sure if i want a speaker for this project yet..
// RGB LEDS - (optional), use 3x 330k resistors for each, can be adjusted
// i wont be using any at this time
// int RGBled1 = 6;
// int RGBled2 = 7;
// int RGBled3 = 8;
// int RGBled4 = 9;
// lcd pins 10 & 11
byte Pennies(); // how many pennies
byte Nickles(); // how many nickles
byte Dimes(); // how many dimes
byte Quarters(); // how many quarters
byte HalfDollars(); // how many half dollars
byte DollarCoina(); // how many dollar coins
byte Savings(); // used for total calculation of amount of money saved - show dollar format including commas where needed
void setup()
{
pinMode(COIN, INPUT);
digitalWrite(COIN, HIGH); // pull up
coins = 0;
int status;
status = lcd.begin(LCD_COLS, LCD_ROWS);
// Print a message to the LCD
// basically the initial setup of how i want it
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" xxxxxxxxxx xxx "); // 1st row - PRIVATE
lcd.setCursor (0, 1);
lcd.print(" xxxxxxx xxxxxxxxx "); // 2nd row - PRIVATE
lcd.setCursor(0, 2);
lcd.print(" xxxxxxxxx xxxx "); // 3rd row - PRIVATE
lcd.setCursor(0, 3);
lcd.print("xxx xxxxxx xxxxxxxxx"); // 4th row - PRIVATE
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Quarters: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 1);
lcd.print("Dimes: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 2);
lcd.print("Nickles: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 3);
lcd.print("Pennies: 0"); // text to the left side and count right side if possible, use commas
delay(3000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Halves: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 1);
lcd.print("Dollar: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 2);
lcd.print(" Total Coins: "); // text to the right side and count left side if possible, use commas
lcd.setCursor(0, 3);
lcd.print("0"); // count right side if possible, use commas
delay(3000);
lcd.clear();
// now go to main INSERT COINS screen
}
void loop()
{
lcd.setCursor(0, 1);
lcd.print(" INSERT ");
lcd.setCursor(0, 2);
lcd.print(" CHANGE ");
delay(500);
lcd.clear();
delay(500);
// while the coin pin is low (no coin detected), do nothing
while (! digitalRead(COIN)) {
delay(1);
}
In a galaxy far away...
“Forget about a coin mech”
Start on your basic skills.
Put two buttons on a breadboard.
Learn how to detect a press on button #1
Once you have that sorted, figure out how to count the number of pushes on button #2
A little while later, see if you can clear the press count, and enable button #2 with button #1
Show us that code. There are a number of tutorials and intro sketches to do all that. You just need to look.
Arduino button press
Arduino counting pulses
Once you have the button/pulse detection working reliably, leave it alone and display that activity on the LCD
Once that’s done, we can help you sort/count specific denominations
This is called modular programming.
Bottom-Up, so you know the fundamentals will work when you need them.
The way you’ve been asking for help is going to (already has) made work frustrating and hard for you, because nothing just ‘falls into place by itself’.
Writing software (and building hardware) is a skilled, lengthy and considered process. No shortcuts unless you’re using LEGO mindstorms. which could be one way to avoid learning Arduino methods.
Good advice. Although, VID 1 hands you the code you're asking for on a Silver Platter.
lastchancename:
Start on your basic skills.
Put two buttons on a breadboard.Learn how to detect a press on button #1
Once you have that sorted, figure out how to count the number of pushes on button #2
A little while later, see if you can clear the press count, and enable button #2 with button #1
been there done that when i first started arduino awhile back with a digit led.. it's the part about counting pulses and such and really without the unit here, i guess there isn't much more i can do.. so i'll just continue waiting for the unit to come and take a break from here until then...
We can’t help you unless you want to help yourself.
If you think the coin mech is going to change something - go ahead keep hoping. It will arrive, then you’ll start bleating the same questions.
Go look for Arduino pulse counter- you may learn something.
It won’t be your complete program*, but you’ll have an understanding and maybe some code to help you get there.
Ok, so in your estimation you have button #1 sorted, how about counting pulses on button #2
It won’t kill you, and when the mech arrives, you can move forward.
But at the moment, there’s nothing anyone can do for you if you refuse to follow or engage with suggestions.
this is what i came up with so far.. i guess next will be the pulse counting... i rather have the machine on hand instead of just coding blindly.. so i shall continue to wait for it to come in.
#include <Wire.h>
#include <hd44780.h> // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
hd44780_I2Cexp lcd; // declare lcd object: auto locate & config exapander chip
// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;
int Coins = 2; // white wire from coin acceptor
int ResetButton = 3; // hidden inside and resers All counts, no turning back
int MenuButton = 4; // controlls lcd screen
//int Speaker =5; // not being used at this time
// lcd screen pins
int Savings;
int Pennies;
int Nickles;
int Dimes;
int Quarters;
int HalfDollars;
int DollarCoins;
int ResetButtonState = 0;
int MenuButtonState = 0;
void setup() {
// put your setup code here, to run once:
int status;
status = lcd.begin(LCD_COLS, LCD_ROWS);
pinMode(Coins, INPUT);
pinMode(ResetButton, INPUT);
pinMode(MenuButton, INPUT);
//pinMode(Speaker, OUTPUT); // not being used at this time
// if reset button is pressed, reset ALL counts - no turning back
ResetButtonState = digitalRead(ResetButton);
ResetAll();
// if MenuButton is pressed, change lcd accordingly
switch (MenuButton) {
case 1:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Quarters: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 1);
lcd.print("Dimes: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 2);
lcd.print("Nickles: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 3);
lcd.print("Pennies: 0"); // text to the left side and count right side if possible, use commas
delay(3000);
break;
// go back to main loop if menu button is not pressed again for second case
case 2:
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Halves: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 1);
lcd.print("Dollar: 0"); // text to the left side and count right side if possible, use commas
lcd.setCursor(0, 2);
lcd.print(" Total Coins: "); // text to the right side and count left side if possible, use commas
lcd.setCursor(0, 3);
lcd.print("0"); // count right side if possible, USE COMMA FORMAT
delay(3000);
break;
// now go back to main loop, if button is pressed again go back to case 1
}
}
void loop() {
// put your main code here, to run repeatedly:
// i could use a state machine for this, but not going to right now.. easier and smaller coding this way
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" INSERT ");
lcd.setCursor(0, 2);
lcd.print(" CHANGE ");
delay(500);
lcd.clear();
delay(500);
}
void ResetAll() {
int Savings = 0;
int Pennies = 0;
int Nickles = 0;
int Dimes = 0;
int Quarters = 0;
int HalfDollars = 0;
int DollarCoins = 0;
lcd.clear();
lcd.setCursor(0, 1);
lcd.print(" SAVINGS ");
lcd.setCursor(0, 2);
lcd.print(" CLEARED ");
delay(500);
lcd.clear();
// now go back to main loop
}
I still don’t see any code to count ‘pulses’.
A button during testing will be a lot easier than fussing with the mechanism
You don’t have to do this, but if I wanted to write code without the mech, that’s the way I’d be going. Each to his own.