|
Forum Index : Microcontroller and PC projects : PicoMite ' PORT ' ......
| Author | Message | ||||
| hitsware2 Guru Joined: 03/08/2019 Location: United StatesPosts: 735 |
' 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 StatesPosts: 3480 |
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 StatesPosts: 735 |
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 StatesPosts: 3480 |
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 StatesPosts: 735 |
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 ZealandPosts: 9757 |
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 StatesPosts: 3480 |
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 |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |