Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4544

Troubleshooting • Help Rpm Counter inputs

$
0
0
hello, I am a miller, and am trying to make a speed counter for my old historic mill, I use a pi5 8G bookworm.
Like everyone else, you will look for something you can use, and try to adapt it to how it works on my Pi5, input gpio27, my program runs flawlessly, but does nothing, I think the input is not being read properly? ?? What should I change about it?
Thanks


import gpiod
import time
SENSOR_PIN = 27


count = 0

def get_rpm():
global count
if count == 0:
count = count + 1 # increase counter by 1
else:
#time.sleep(0.02)
count = count + 1
print("updating"+ str(count) )



def setup():
chip = gpiod.Chip('gpiochip0')
sensor_line = chip.get_line(SENSOR_PIN)
sensor_line.request(consumer="Sensor", type=gpiod.LINE_REQ_DIR_IN)


def loop():
while True:
time.sleep(1)
print(count)

def destroy():
gpiod.cleanup() # Release resource

if __name__ == '__main__': # Program start from here
setup()
try:
print("start loop")

finally:
print ("")

Statistics: Posted by Bregt — Sat Sep 14, 2024 2:23 pm — Replies 1 — Views 52



Viewing all articles
Browse latest Browse all 4544

Trending Articles