40x1 - Reading Portc pins - AGAIN

manie

Senior Member
I have done a search and I have read the posts.
I have really read the manual Appendix F regarding PortC.
Posts and the manual says you can use:
IF portc pin 0 = 1 THEN
However, the following error is reported in the syntax check result window:
IF portc pin 0 = 1 THEN
^

Error: Syntax error in this line!
How can I get the status of PortC pins 0-3 ?

Sorry if this has been trodden through already but the manual is not really clear, neither are the posts.
Thanks for your help.....
Manie
 

eclectic

Moderator
@Manie

#picaxe 40x1

If portc pin0 = 1 then

goto finish
endif

finish:

No space between pin 0

e
 
Last edited:

manie

Senior Member
Sorry, that was a Control_C copy of example code by Dippy in one of the posts he answered. Space removed, problem cleared.... Thanks. It is a bit of a round-about wayto read PortC though....

Thanks all !
Manie
 

manie

Senior Member
"Select Case - End Select" is what I prefer to use instead of multiple "If....then" statements. This also produces an error:
select case portc pin0
^

Error: Syntax error in this line!
Does this mean you can ONLY use If....then statements with PortC input pins ?
 

hippy

Ex-Staff (retired)
PORTC can be used with IF, HIGH and LOW commands. It is not supported with SELECT-CASE.
 

eclectic

Moderator
This is convoluted, but does work on a real 40X1.

The PortD version also works in simulation.

Code:
#picaxe 40x1

main:
b0 = pins ; for default PortD inputs
 
; peek $07,b0 ; Alternative for PortC 
 
sertxd ("Inputs= ",#bit7,#bit6,#bit5,#bit4,#bit3,#bit2,#bit1,#bit0,cr,lf)
; sertxd for testing only


select case bit1 ; (uses example output 1)

case 0
low 7 ; or whatever
case 1
high 7 ; or whatever

; and so on
endselect

pause 500
goto main

#rem
;tested using 
;switch on input 1 / Leg20/ portd 1
;OR inC1 / leg16

;Un-used inputs grounded
;switch-press  lights an LED on o/p7

See Man.1 p.86
and Man.2 p 10 and 167

Ideas pinched from Hippy's previous posts.  :-)
It might be a basis for experiment

e
 

manie

Senior Member
Hippy: Thanks. :D

At some point in the future it would be good if Technical could find time :) to add some more clarity regarding this (and "other" issues) in the manual/s, something like Hippy's answer above included in the manual/s will cover a lot of distance.;)
 

manie

Senior Member
EC: That also looks do-able, Thanks. (I was answering Hippy's post...)

Edit:

PS. I'm still waiting for my BB from That-bay..... then I can play easier !
 
Last edited:

manie

Senior Member
EC: Have read the thread, I'm starting to use (and understand) masking, so thats OK.

I am using some pins on PortC (40x1) as digital inputs and some as outputs (Hserin/Hserout and PortC pin4 as output). Does PEEK'ing $07 still return the desired results on the remaining pins used for input ?
 
Top