Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:57 19 Feb 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Confused by SETPIN

Author Message
pwillard
Guru

Joined: 07/06/2022
Location: United States
Posts: 337
Posted: 07:16pm 02 Jan 2026
Copy link to clipboard 
Print this post

Trying new version 6 firmware on my old RP2040.

Now I'm confused.

Using the MANUAL example:


SETPIN GP21, DOUT
DO
PIN(GP21) = 1
PAUSE 300
PIN(GP21) = 0
PAUSE 300
LOOP


I get blinking on GPIO pin 16


Using this code:



SETPIN GP16, DOUT

DO
 PIN(16) = 1
 PAUSE 100
 PIN(16) = 0
 PAUSE 100
LOOP


I get fast blinking on pin 12.

???
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3618
Posted: 07:29pm 02 Jan 2026
Copy link to clipboard 
Print this post

Pin(16) is GP12. You must use either the pin numbers or the GP numbers--they aren't the same.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
pwillard
Guru

Joined: 07/06/2022
Location: United States
Posts: 337
Posted: 07:31pm 02 Jan 2026
Copy link to clipboard 
Print this post

I think I forgot that... its been a while.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8568
Posted: 08:14am 03 Jan 2026
Copy link to clipboard 
Print this post

Please don't use hardware pin numbers at all if you can avoid it. Doing so can completely screw up compatibility between your software and different hardware platforms.  :(  The chip itself uses the GPIOxx format, which MMBasic kindly abbreviates to GPxx to save our poor fingers, the I and O keys.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Canada_Cold
Regular Member

Joined: 11/01/2020
Location: Canada
Posts: 52
Posted: 12:31pm 09 Jan 2026
Copy link to clipboard 
Print this post

Hi,

Regarding using GPxx numbers rather than pin numbers, is there a way to address the GPxx as a variable?

In the following code snippet I used the pin number;

DIM INTEGER PINOUT
PINOUT = 14          ' GPIO10
SETPIN PINOUT, DOUT
PIN(PINOUT) = 0      ' Pinout = low  

Is there a better way to do this?

Don
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5703
Posted: 12:40pm 09 Jan 2026
Copy link to clipboard 
Print this post

Hi Don,

there is a way using pin numbers derived from GPxx.


CONST pinout=MM.INFO(PINNO GP10) 'there is a number associated to GP10
SETPIN pinout,DOUT
PIN(pinout)=0


Why is this better ? Simply because pin 14 is connected to GP10 in a genuine RP pico, but in a different board it could be on a different pin (i.e. 16). And GP10 is universal.

Volhout
Edited 2026-01-09 22:50 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Canada_Cold
Regular Member

Joined: 11/01/2020
Location: Canada
Posts: 52
Posted: 03:15pm 09 Jan 2026
Copy link to clipboard 
Print this post

Hi Volhout,

Thank you for your post and the code example.  I hadn’t considered that the pin numbering might be different on non RP boards.    It certainly makes good coding to use the GP numbers.  I’ll have to implement this in my code now.

Thanks again, Don
 
homa

Guru

Joined: 05/11/2021
Location: Germany
Posts: 539
Posted: 05:42pm 09 Jan 2026
Copy link to clipboard 
Print this post

  Volhout said  
there is a way using pin numbers derived from GPxx.


CONST pinout=MM.INFO(PINNO GP10) 'there is a number associated to GP10
SETPIN pinout,DOUT
PIN(pinout)=0


Why is this better ? Simply because pin 14 is connected to GP10 in a genuine RP pico, but in a different board it could be on a different pin (i.e. 16). And GP10 is universal.


@Volhout thx!

@geoff That should be included in the manual as a pro tip.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3016
Posted: 08:42pm 09 Jan 2026
Copy link to clipboard 
Print this post

An example of using it to set a row of pins.
Dim integer n, Start.Pin.GP = 0, No.of.Pins = 8

For n = Start.PinGP To Start.Pin.GP + No.of.Pins - 1
  SetPin MM.Info(pinno "GP"+Str$(n)), DOUT 'set the Port output pins
Next

Edited 2026-01-10 13:31 by phil99
 
pwillard
Guru

Joined: 07/06/2022
Location: United States
Posts: 337
Posted: 08:20pm 10 Jan 2026
Copy link to clipboard 
Print this post

Thanks for the tips.  Much appreciated.
 
Canada_Cold
Regular Member

Joined: 11/01/2020
Location: Canada
Posts: 52
Posted: 07:53pm 14 Jan 2026
Copy link to clipboard 
Print this post

Hi,

I just wanted to say thanks to Volhout and to phil99 for your input and the code examples.  That was very helpful.

I also agree with homa, it would be nice to have examples in the manual.  And if not in the manual, maybe on the fruitoftheshed.com website and referenced in the manual.

Don
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026