let b0 = portc pin5 problem

taux3

Member
I am trying to send the value of a touch sensor (on-off button) to variable b0 but the touch sensor is connected to portc pin5 of a 40X.

let b0 = portc pin5 doesn't work ?!?!! Why ?!?!

Thanks
Antony
________
glass pipes
 
Last edited:

eclectic

Moderator
Antony

Just use input5

This works, in the simulator and for real.
Code:
#picaxe 28x1
main:

let b0 = input5
sertxd (#b0, cr,lf)
pause 1000
goto main
e
 

westaust55

Moderator
Antony

Just use input5

This works, in the simulator and for real.
Code:
#picaxe 28x1
main:

let b0 = input5
sertxd (#b0, cr,lf)
pause 1000
goto main
e

portC are the default inputs on on a 28X/X1
but on the stated 40X (and the40X1) portD is the default inputs.

port C has a far more limited range of commands.
 

westaust55

Moderator
I am trying to send the value of a touch sensor (on-off button) to variable b0 but the touch sensor is connected to portc pin5 of a 40X.

let b0 = portc pin5 doesn't work ?!?!! Why ?!?!

Thanks
Antony
portc on the 40X/X1 has a limited capability in terms of commands.

have a look at PICAXE manual 1 page 86 which dicusses the use of portC.

Typically as inputs you are limited to commands like:
IF portc pin 0 = 1 THEN goto xxxx

and as outputs to commands like:
HIGH portC 1
 

hippy

Ex-Staff (retired)
let b0 = portc pin5 doesn't work ?!?!! Why ?!?!
In short, it's not supported syntax and the underlying PICAXE firmware cannot deal with the intention in that manner. What you need to do is -

If PortC pin5 = 1 Then
b0 = 1
Else
b0 = 0
End If
 

eclectic

Moderator
Thank you WA.
I should have read the question. :-(

This is OK on a real 40X1
(but I can't test it in the simulator)

Code:
#picaxe 40X1
main:

if portc input5 = 1 then 
b0 = 1
else b0 = 0
endif

sertxd (#b0, cr,lf)
pause 1000
goto main
e
 

westaust55

Moderator
e.

I have previously put the suggestion forward in the PE section of this forum that Rev Ed should work towards having a proper 40 pin PICAXE chip simulator in the next revison of the PE, as the portC/portD issue and not being able to simulate portE (extra ADC inputs on the 40pin devices) are amongst drawbacks with the current concept of using a 28X1 selection to 40X1 chips.
 
Top