GPIO on Raspberry Pi
Posted: Monday 27th July 2020 1:39pm
Hello everybody - my name is Peter - I´m not new to Basic but to Gambas! So one could say I´m a Gambas newbie. I have a Raspberry Pi 3 B and Gambas 3.12.2. Years ago I wrote a program in BASCOM for my selfmade Geigercounter to measure natural background radiation. Now I´m trying to convert this program to the raspberry pi using Gambas. It´way harder than I thought This is what I "achieved" so far:
'determine GPIO 23 = Pin 16 as Input / pull-up Resistor to +Ub
Shell "gpio -g mode 23 in up"
' enable Timer1 for polling
Timer1.Enabled = True
Timer1.Delay = 100
Shell "gpio -g read 23" 'read the content of pin 16
' If...
End
Now my question is how do I transfer the value of pin 16 to variable? Is there a better method for polling an input pin in Gambas?
Public Sub Form_Open()
'determine GPIO 23 = Pin 16 as Input / pull-up Resistor to +Ub
Shell "gpio -g mode 23 in up"
' enable Timer1 for polling
Timer1.Enabled = True
Timer1.Delay = 100
Shell "gpio -g read 23" 'read the content of pin 16
' If...
End
I´m far from sure if this is even going - I would need to know the state of pin 16 where the geigercounter is connected to - a negative edge means a count - the counts have to be added for one minute to get the cpm (counts per minute) - then the values could be displayed and/or written to a logfile. My Bascom program used Interruptprogramming for this purpose - I don´t know if this is possible with Gambas.
Now my question is how do I transfer the value of pin 16 to variable? Is there a better method for polling an input pin in Gambas?