Go Down

Topic: Pulse Reading from Coin slot to Arduino (Read 3 times) previous topic - next topic

Gedon

#10
Dec 19, 2012, 04:58 pm Last Edit: Dec 19, 2012, 05:10 pm by Gedon Reason: 1
As another checking if there really is a change in the pulsing in the signal wire, w/ a circuit inbetween the signal wire (the wire that gives supposedly a pulse signal) to the arduino, i have connected a LED in between.

With or w/out this circuit in between THEY HAVE THE SAME RESULT.

the thing is as i turned on the coin slot and the arduino, as well as the LCD and all of them being connected, the LED in the circuit is continuously lit up. As I inserted the a coin it shows a change and blinks:
When P1.00 coin is inserted, it blinks once.
When P5.00 coin is inserted, it blinks 4 times.
When P10.00 coin is inserted, it blinks 8 times.




Gedon

Just a Quick Question about Arduino...
If i'm using PIN 2 as Interrupt pin, does the required voltage, being above 3V is HIGH and below 3V is LOW, still a necessity?

Nick Gammon

Does that gadget just open/close a switch? If so you hardly need those transistors. Or does it output a voltage?

If it closes a switch you just need to set pin 2 to INPUT_PULLUP, and then detect a FALLING interrupt (that would be when the switch is closed). In other words, wire the switch from pin 2 to ground, and when the switch closes pin 2 will become low briefly. Don't use a LOW interrupt, that will tend to hang up your program.

Check with a meter if there is a voltage output, or just a switch closure.


strykeroz


Just a Quick Question about Arduino...
If i'm using PIN 2 as Interrupt pin, does the required voltage, being above 3V is HIGH and below 3V is LOW, still a necessity?
Hi

I'm not at all sure of the 3V value you're quoting here.  Unless I'm reading the datasheet incorrectly (which is a possibility, granted), when VCC is in the range 2.4V - 5.5V, the highest value where the pin is guaranteed to be read as low is 0.3V and the lowest value where the pin is guaranteed to be read as high is 0.6V. (this is from Page 313, section "28.2 DC Characteristics").

The interrupt section of the datasheet does not list alternative voltages for low and high so I expect the same rules apply, though others will have greater experience in this area.

Cheers  ! Geoff
"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Gedon

THANK YOU SO MUCH for the suggestions/advice/comments.
This is the code now:
Code: [Select]

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 6, 5, 4, 3);
volatile int coins = 0;

void setup()
{
  lcd.begin(16, 2);
  pinMode (2,INPUT_PULLUP);
  attachInterrupt(0, coinInserted, FALLING);
}
void coinInserted()
{
  coins = coins + 1;
}
void loop()
{
  lcd.setCursor(1,0);
  lcd.print(coins);
}


On the LCD display, when i turn on the Arduino and the Coin Slot, it displays 1 and not 0 so i assume it already read a pulse when turned on, but still it counts the way i need it to count. It doesn't count up continuously anymore, and counts up respectively to what coin is inserted. Still starting from 0 and not 1 would be a bit more of a convenience to me than finding a way to get rid of the unnecessary 1 on start. Thanks for the Help!  XD

Go Up