This is what i want to do:
(A).Take one pulsh on pin2 turns ledPin HIGH.If takes five pulsh on pins4 turn ledPin LOW.
(B).Take two pulsh on pin2 turns ledPin HIGH.If takes ten pulsh on pins4 turn ledPin LOW.
(C).Take four pulsh on pin2 turns ledPin HIGH.If takes twenty pulsh on pins4 turn ledPin LOW.
(D).....
(E).... go on.
My problem is:
(i use button to tested)
When i pressing buttonPin(pin2) one time turns ledPin HIGH and if i press buttonPinb(pin4) five times turn ledPin LOW.so far so good.
When i pressing buttonPin(pin2) two times turns ledPin HIGH and if i press buttonPinb(pin4) five times turn ledPin LOW.(not ten).
The same happens in all situations.The ledPin turn LOW with five pulsh. No matter how many times I pressed the buttonPin(2).
Thanks to all!
This is what i have done in sketch:
const int buttonPin = 2;
const int buttonPinb = 4;
const int ledPin = 13;
int buttonPushCounter = 0;
int buttonPushCounterb = 0;
int buttonState = 0;
int buttonStateb = 0;
int lastButtonState = 0;
int lastButtonStateb = 0;
I'm looking to find a way that I have all 3 situations(A B C) in the program.
If i give 1 pulse to pin2 do the ledPin HIGH and if i give 5 pulse to pin4 do the ledPin LOW,
if i give 2 pulse to pin2 do the ledPin HIGH and if i give 10 pulse to pin4 do the ledPin LOW
and finaly if i give 4 pulse to pin2 do the ledPin HIGH and if i give 20 pulse to pin4 do the ledPin LOW.
I want to make a program that when given a pulse(if one pulse do ledPin HIGH) wait to get five pules(if five pulse do ledPin LOW) and when given two pulses (if two pulse do ledPin HIGH) wait to get ten pulse(if ten pulse do the ledPin LOW) and when give four pulses(if four pulse do ledPin HIGH) wait to get twenty pulse(if twenty pulse do the ledPin LOW).
Yes yes yes!!!!! 1on=5off, 2on=10off, 4on=20off in different pins (1,2,4, on pin2) and (5,10,20 on pin4)
I have a bill acceptor when takes 5 euro bill gives 1 pulse,when takes 10 euro bill gives 2 pulse and when takes 20 euro bill gives 4 pulse.
the pulse time is 50ms per pulse.
And a have a hopper(coin counter machine) when hopper is on, extract and counting the coins (5-7 coins per sec).?ach coin is 1 pulse.
The hopper is counting coins.How counting coins: when extract 1 coin gives 1 pulse when extract 2 coins gives 2 pulse etc.
when you take 5 euro(1 pulse on pin2)turn hopper on, and wait the hopper to gives you 5 pulse on pin4(5 coins of 1 euro)then turn hopper off, if you take 10 euro(2 pulse on pin2)turn hopper on, and wait the hopper to gives you 10 pulse on pin4(10 coins of 1 euro)then turn hopper off and if you take 20 euro(4 pulse on pin2)turn hopper on, and wait the hopper to gives you 20 pulse on pin4(20 coins of 1 euro)then turn hopper off.
He wants to dispense 1 euro coins when someone puts in 5, 10, or 20 euro bills.
For each 5 euro of bill value the bill detector sends a pulse: 1 for a 5 euro note, 2 for a 10 euro note and 4 for a 20 euro note.
For each pulse of the input he wants the coin dispenser to dispense five coins. Each time it dispenses a coin it produces one pulse. When done dispensing he turns the dispenser (represented by the LED) off.
So far he has not commented on the code I provided to do exactly that.
Mr. johnwasser your program works perfectly, but I try to add the action for other banknotes and coins but i can not find the way.
I dont speek good english,but i'm trying.
KE7GKP:
Still not clear to me whether the 5x coin count is an INPUT (as implied in the question) or an OUTPUT. Perhaps that is why I am confused. I would think that a change machine would take in paper currency (counted by the pulses from the bill acceptor) and then OUTPUT pulses to the coin dispenser.
My understanding is that the coin dispenser has an on/off input (represented by the LED) and a pulse output which signals that a coin has been dispensed (represented by the second button). The program turns on the coin dispenser until the right number of coins have been dispensed and then turns off the coin dispenser.