Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:56 19 Nov 2025 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 : PicoMite ' PORT ' ......

Author Message
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 735
Posted: 12:22am 11 Nov 2021
Copy link to clipboard 
Print this post


' PORT test

SetPin gp16,din,pullup
SetPin gp17,din,pullup
SetPin gp18,din,pullup
SetPin gp19,din,pullup
Print Pin(gp16)
Print Pin(gp17)
Print Pin(gp18)
Print Pin(gp19)
Print Port(gp16,gp17,gp18,gp19)

' Gives me:
'1
'1
'1
'1
'0
'
'Also if I try just 3 pins,
'I get 'syntax' error on PRINT PORT ?

my site
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3480
Posted: 12:59am 11 Nov 2021
Copy link to clipboard 
Print this post

Try this:

SetPin gp16,din,pullup
SetPin gp17,din,pullup
SetPin gp18,din,pullup
SetPin gp19,din,pullup
Print Pin(gp16)
Print Pin(gp17)
Print Pin(gp18)
Print Pin(gp19)
Print Port(gp16,4)
Print "0x"+Hex$(Port(gp16,4))
Print "0b"+Bin$(Port(gp16,4))

See PIN in the Functions list in the manual, not the Commands list, to see why.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 735
Posted: 01:15am 11 Nov 2021
Copy link to clipboard 
Print this post

Thank You ! ...  
I ' ve decided to use :

p=pin(gp16)+2*pin(gp17)+4*pin(gp18)+8*pin(gp19)

So I don't have to use consecutive pin numbers .
my site
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3480
Posted: 01:28am 11 Nov 2021
Copy link to clipboard 
Print this post

You don't have to use consecutive pin numbers. This also works:


SetPin gp16,din,pullup
SetPin gp17,din,pullup
SetPin gp18,din,pullup
SetPin gp19,din,pullup
SetPin gp20,din
SetPin gp22,din,pullup
Print Pin(gp16)
Print Pin(gp17)
Print Pin(gp18)
Print Pin(gp19)
Print "0b"+Bin$(Port(gp16,1,gp18,1,gp20,1,gp22,1))

PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
hitsware2

Guru

Joined: 03/08/2019
Location: United States
Posts: 735
Posted: 01:54am 11 Nov 2021
Copy link to clipboard 
Print this post

Set a number of I/O pins simultaneously (i.e. with one command).
'start' is an I/O pin number and the lowest bit in 'value' (bit 0) will be used to
set that pin. Bit 1 will be used to set the pin 'start' plus 1, bit 2 will set pin
'start'+2 and so on for 'nbr' number of bits.

I/O pins used must be numbered consecutively

and any I/O pin that is invalid or not configured as an output
will cause an error. The start/nbr pair can be repeated if an additional group
of output pins needed to be added.
For example; PORT(15, 4, 23, 4) = &B10000011
Will set eight I/O pins. Pins 15 and 16 will be set high while 17, 18, 23, 24
and 25 will be set to a low and finally 26 will be set high.
This command can be used to conveniently communicate with parallel
devices like LCD displays. Any number of I/O pins (and therefore bits) c
my site
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9757
Posted: 04:37am 11 Nov 2021
Copy link to clipboard 
Print this post

Yes, if you specify MORE then ONE pin in the PORT command, the pins have to be consecutive.  However, as illustrated by lizby above, you can have completely random pin numbers making up the port, but you have to specify them all separately and as only one pin each.
Smoke makes things work. When the smoke gets out, it stops!
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3480
Posted: 12:39pm 11 Nov 2021
Copy link to clipboard 
Print this post

  hitsware2 said  Set a number of I/O pins simultaneously (i.e. with one command).


With "set", you're using PORT as a command. If you do PRINT PORT ..., then PORT is a function.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
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 2025