Hello I'm a college student and we have a project in our class and I was assigned into making a coin sorter, the hard part is we didn't have knowledge about programming rpi and some codes are new to us so if any help could be a lot. The project is having the i2c backlight lcd show the count and the activator of the coin counter is the wire attached to a copper or a flat metal which causes the the two wires to connect when the coin is dropped. I researched a lot of projects about this but I only saw them using arduino, and I think arduino used c++ language. I'm willing to learn the deadline is just giving the pressure.
-
I suggest you now do "research" with the phrase raspberry pi in the search terms.– joanFeb 19 at 16:12
-
I did and none of them use raspberry. That is why I am here– REMFeb 19 at 16:18
-
This is the wrong site for this type of request. It might be treated with more sympathy at the raspberry pi forums.– joanFeb 19 at 16:22
-
2break the project into small pieces and solve each piece individually ... for example, the coin drop sensor connects two wires together ... that is same as a switch ... write code that counts button presses– jsotolaFeb 19 at 18:06
-
Thank you so much for the suggestion, I found a video simmilar to the project I've been doing the only problem is how can I project and monitor it with the i2c, thank you so much this helps me a lot.– REMFeb 20 at 1:57
1 Answer
Hello and thank you all for help, I've managed to learn how to code and finish my work and it's fully functioning. I'll drop my code here for anyone who may wants it. `
from RPi_GPIO_i2c_LCD import lcd
from time import sleep
from time import *
from gpiozero import Button
i2c_adress = 0x27
lcd = lcd.HD44780(i2c_adress)
count = 0
one_peso = Button(14)
five_peso = Button(27)
ten_peso = Button(23)
twenty_peso = Button(17)
start = Button(24)
try:
while True:
lcd.set(' Coin Sorter', 1)
lcd.set(' P' + str(count), 2)
if one_peso.is_pressed:
one_peso.wait_for_press()
one_peso.wait_for_release()
count = count +1.00
print(count)
if five_peso.is_pressed:
five_peso.wait_for_press()
five_peso.wait_for_release()
count = count +5.00
print(count)
if ten_peso.is_pressed:
ten_peso.wait_for_press()
ten_peso.wait_for_release()
count = count +10.00
print(count)
if twenty_peso.is_pressed:
twenty_peso.wait_for_press()
twenty_peso.wait_for_release()
count = count +20.00
print(count)
except KeyboardInterrupt:
lcd.set(' Cleaning up', 1)
lcd.set(' Goodbye', 2)
sleep(1)
lcd.clear()
sleep(1)
exit()