Using ADC Inputs as Digital

Dominic B

New Member
I'm using a 28X1, but am a bit short on I/Os so I'm currently using three of the adc inputs as digital inputs. I know I can use
Code:
	readadc 0,b0
and then
	if b0>200 then flash
but is there a way of using those inputs as digital rather than analogue, or without needing to assign them to a variable?

Thanks,
Dominic
 

jsch2603

New Member
Here's an excerpt from the PICAXE manual I (p79) which I think is what you are looking for:

Using porta as digital inputs
The porta pins 0 to 3 (legs 2 to 5) are, by default, configured as analogue
inputs.
However they can also be used as simple digital inputs.

The following syntax is used to test the input condition:
if porta pin0 = 1 then jump
i.e. the additional keyword ‘portA’ is inserted after the ‘if’ command.
to test if two (or more) porta inputs are on
if porta pin0 = 1 AND pin1 = 1 then jump
to test if either of two (or more) porta inputs are on
if porta pin0 = 1 OR pin1 = 1 then jump

Note the portA command is only required once after the ‘if’ command.
It is not possible to test inputs on two different ports within the same if…then
statement.

It is not possible to access the portA pins with any other ‘input’ type commands (count, pulsin etc). Therefore these pins should be reserved as simple on/off switches.
 

Dominic B

New Member
Yes, you're probably right Andrew, but the pin diagram looks more or less the same (in the basics at least)

Thanks jsch2603, that was exactly what I was looking for!

eclectic, thanks for that, but assuming I understand it correctly, I think it's concerning something different to my question.
 

westaust55

Moderator
It's actually a 28X, not a 28X1.

Andrew
Dominic,
If andrew knows you, then yes he could be correct.
As you say, both have the same basic pin layout.
The 28X is an older chip which was superceded by the 28X1. (see manual 1 page 10) I believe that Rev Ed no longer produce the 28X.

If you have a 28X1, it has an internal oscillator and can operate without an external oscillator/resonator at 4MHz and 8MHz.
The 28X1 also has some other features that will be of benefit as you get deeper into the use of your PICAXE chip.
 
Top