-
Notifications
You must be signed in to change notification settings - Fork 48
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
Use #16
Comments
What have you tried? What error messages are you seeing? What is TX2? You should be able to setup the pin with |
Sorry, I was talking about the Nvidia Jetson TX2,
Maybe it's coming from the pin number, should I use number between 1 and 40 or the number provided by the description document (using sysfs) ? Also to "read" the value, is it the function read or output ? |
use You should only use Sorry, I don't know what the problem is for you particular use case. Make sure your user has the appropriate permissions (you can try |
Thank you for your answer, but when I use gpio.IN it tells me 'gpio not defined', however it does work with 'in'... Can you tell me if I should use the pin number (1 to 40) or the LinuxGPIO number (random number like 395 or 410 etc...) ? |
I don't know. That is very device dependent and I don't know the details of
your device, sorry.
|
with nvidia tx2 devkit this code works. import gpio
import time
trig = 394
echo = 393
print "HC-SR04 Sonar"
gpio.setup(trig,gpio.OUT)
gpio.setup(echo,gpio.IN)
while True:
gpio.set(trig,0)
print "Measure..."
gpio.set(trig,1)
time.sleep(0.00001)
gpio.set(trig,0)
pulse_start = time.time()
while gpio.read(echo)==0:
pulse_start = time.time()
pulse_end = time.time()
while gpio.read(echo)==1:
pulse_end = time.time()
pulse_duration = pulse_end - pulse_start
distance = pulse_duration * 17150
distance = round(distance, 2)
print "Distance" , distance |
I think @ikoc is right on the issue. |
I would welcome the submission of examples- perhaps in an "examples" dir of this repository- to demonstrate use on various platforms and help get users off to a running start. In the interim I'll tag this issue up as a "notice" and leave open for future users. |
Hi vitiral,
I'm new on TX2 and python and I'm struggling using your gpio.py: how should I call the pins in my python program ?
Thanks in advance
The text was updated successfully, but these errors were encountered: