CH-926 Multi Coin Acceptor 6 Coins

CH-926 Multi Coin Acceptor 6 Coins Vending machine/Arcade game machine Programmable CPU Coin Selector intelligent Coin Validator


190 ₪

الناشر: متجر القطع الالكترونية

القسم: مستشعرات - سينسور

تاريخ النشر: 2025-02-05




with esp32



After you have successfully programmed your coin acceptor you can start connecting it to your chosen Microcontroller. I have used an ESP32 development board as I would need its WiFi capability in a separate project later. The universal coin acceptor would oftentimes output a short burst of signal that we can use to track the denomination of the coin that was inserted. For example in the image above, a single peso (Philippine 1 Peso Coin) would output a single high-to-low transition or what they commonly call a FALLING edge. On the other hand, a 5 peso coin would result in five high-to-low transitions. To detect these transitions we could take advantage of the interrupt pins on our Microcontroller and count the number. We need to write ISR (interrupt Service Routines) functions that would be notified when the Falling edge transition is detected on our interrupt pins. This is how easy it is to read the amount of coins that were inserted into our coin acceptor.



code
نسخ
اقتباس
عرض
تنزيل
	
								
void IRAM_ATTR isr() { coinInserted = true; updateDisplay = true; }




Make sure to add a 10K Ohms pull-up resistor to the COIN or signal line of the Coin Acceptor.



library



CODE for coin acceptor ch926

code
نسخ
اقتباس
عرض
تنزيل
	
								
#include <Arduino.h> #include <EEPROM.h> #include <elapsedMillis.h> // Sum of all the coins inseted int totalAmount = 0; volatile bool updateDisplay = false; volatile bool coinInserted = false; elapsedMillis timer; elapsedMillis countDownTimer; long interval_timer = 10000; bool countDownStarted = false; const uint8_t PIN = 19; void IRAM_ATTR isr() { coinInserted = true; updateDisplay = true; } void setup() { Serial.begin(9600); attachInterrupt(PIN, isr, FALLING); Serial.println("Begin coin counter..."); } void loop() { if (coinInserted) { coinInserted = false; totalAmount = totalAmount + 1; if (totalAmount > 0 && !countDownStarted) { countDownStarted = true; timer = 0; countDownTimer = timer; } } if (totalAmount > 0 && countDownStarted) { if (timer >= interval_timer * totalAmount) { Serial.println("Time is up!"); countDownStarted = false; totalAmount = 0; } } if (countDownTimer >= 1000) { if (countDownStarted) { countDownTimer = 0; long timeLeft = ((interval_timer * totalAmount) - timer) / 1000; Serial.print("timeLeft :"); Serial.println(timeLeft); } } }


سلة المشتريات افراغ السلة