Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New lickometer micropython codes #2

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions devices/lickometer_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from pyControl.hardware import Digital_input, Digital_output

class Lickometer():
"""
Optical lickometer to detect lick events
Device documentation on: https://sanworks.io/shop/viewproduct?productID=1020
Configuration:
Red wire: positive; Purple wire: negative
Wires closer to the 4mm nut: emitter; wires further from: transistor
# All purple wires --> GND
# Transistor positive end --> Digital input port
# Emitter positive end --> 500 ohm resistor --> Power source
# Add a 40k pull-up resistor between power source and digital input
"""

def __init__(self, lick_port, sol_port, rising_event_A='lick_1', debounce=5, **kwargs):
# Event triggered when pin is pulled down
self.lick_1 = Digital_input(lick_port.DIO_A, rising_event_A, falling_event=None, debounce=debounce, pull=up)
self.SOL_1 = Digital_output(sol_port.POW_A)
self.SOL_1.off()