Rpi3 gpio piin program

Discussions related to network, internet and socket programming; also to serial, parallel, Bluetooth, USB etc.
mikeg
Posts: 101
Joined: Sat 23 Jun 2018, 19:52

Rpi3 gpio piin program

Post by mikeg »

I have created this program to diagnose the function of all the commands in the GIPO library
The end game of this program is to be able to set my pin to HIGH so it can run my relay, which requires a HIGH pin
to operate the relay ( for solar/ battery powered glow plug water heating timer project)

The relay is a 5 volt relay, but the 5 volt is a supply off your Rpi3 5 volt and ground and the relay has a COM connection that gets the signal from your pin for on/off control.

I want to make a few videos showing BBC Basic running my hardware for 93 people in the Programming tools group.

( I had to edit this post to explain what I was trying to ask)
* I was hoping Richard that you might be able to explain why I am getting no pin status other than 0 and I was wanting to control the ON/OFF status of my pin (pin 5 looks safe to use)

And thank you Richard for your time.

Code: Select all

INSTALL @lib$+"gpiolib.bbc"
LET active%=FN_gpio_setup
REM Lets give a pin a purpose
REM Lets tell PIN GIPO 5 that it is a output
REM I am not sure why the library says to use PROC_gio_inp() first. Maybe initialization?
LET pv%=FN_gpio_get(5,6)
PRINT "The current state of pin 5 is : "pv%
PROC_gpio_clr(5,0):REM clear pin 5?
PROC_gpio_inp(5,6)
PROC_gpio_out(5,6) :REM one way or another we are safe, as 5 and 6 are free to use
REM now lets find out what the value of pin 5
LET pv%=FN_gpio_get(5,6)
PRINT "The current state of pin 5 is : "pv%
REM next statement (pin,state) state- 0 neutral,2 pull up, 1 down
PROC_gpio_pull(5,1):REM this should make pin 5 down (active?)
REM now lets see the value of pin 5
LET pv%=FN_gpio_get(5,6)
PRINT "The current state of pin 5 is : "pv%
REM hmm still 0. Lets try set
PROC_gpio_set(5,31) :REM hi?
REM now does it have a value?
LET pv%=FN_gpio_get(5,0)
PRINT "The current state of pin 5 is : "pv%


END
Focus is on code subject. Feel free to judge the quality of my work.
mikeg
Posts: 101
Joined: Sat 23 Jun 2018, 19:52

Re: Rpi3 gpio piin program

Post by mikeg »

Ok I think I see why I cant get a reading. Its because if I set it as a output. So the only way I can test this is with a LED on a 3v or my relay
Focus is on code subject. Feel free to judge the quality of my work.