Memotech-Bill / PicoBB

BBC BASIC for Raspberry Pi Pico
zlib License
32 stars 4 forks source link

PIN I/O #10

Closed georgestheking closed 1 year ago

georgestheking commented 1 year ago

Hi,

I find a program "blink" to SET / RESET pins. What is the syntax to read a PIN STATE ?

Thanks for all

Georges

cuedcad commented 1 year ago

If you want the status of a single pin, try SYS"gpio_get",pin% TO status%:P.status%

For higher speed on repetative calls can try G%=SYS"gpio_get":A%=pin%:S%=USRG% if the pin number i.e. A% is not changing then just need S%=USRG% once set. if you need the pin% to change it can be made faster using an assembler routine

BW

Memotech-Bill commented 1 year ago

blink.bbc is an old program, written before the BASIC command SYS supported the Pico SDK. gpio.c illustrates using SYS to blink the LED, and is the example to follow.

The previous reply shows you how to use SYS to get the GPIO status.