Hi quick question about the picaxe 28x1

Something

New Member
currently i am building a robotic arm and using a picaxe to control a bunch of servo motors.

Anyways i was wondering what are the variable names for pins 2-5(picaxe 28x1) are? for programming purposes, for example variable "pin0" would be used for pin 11 on the data sheet.



thats the only question i have atm if i have more i know where to come anyways thanks
 

lbenson

Senior Member
If you are talking about +legs+ 2-5, Manual 1, Page 28 shows that these are ACD0, ADC1, ADC2, and ADC3--or port A pin 0, 1, 2, and 3. As a digital inputs, you access them, for example, with "if porta pin0 = 1 then" (or "= 0"). Hope that addressed your question.
 

Something

New Member
o boy another problem

as i started to write some code to test it out
i was wondering why doesnt this work

if porta pin0 = 1 and porta pin1 = 1 then main



my next problem is this one its more of a simulator thing

if porta pin0 = 1 then goto main2

how do i represent a 1 in analogue values, i tried changing it to 5 but it doesnt do anything.


Thanks again
 

lbenson

Senior Member
You can break up the compound if into two ifs"
Code:
  if porta pin0 = 1 then
    if porta pin1 = 1 then main
  endif
I'm not certain I understand your second question. I may be missing the proper way to do it, but I can't see how to make the porta pins look like digital inputs in the simulator. But if you move the analog values up past the halfway point, that is to 130, then "if porta pin0 = 1" will be true, and you can simulate that.
 

Something

New Member
dam you are good


as for the second question ya your right i changed it too 255 and it detected it as a high and it works Thanks again
 

womai

Senior Member
You only need to state porta once - it stays valid for the whole line (which also means you cannot mix porta pins and non-porta pins in the same if clause - see the manual!):

if porta pin0 = 1 and pin1 = 1 then main

As for the analog value, you'd need to read it into a variable first:

readadc 0, b0 ' reads porta pin 0 analog voltage into b0
if b0 >= 128 then
....


Wolfgang
 

westaust55

Moderator
currently i am building a robotic arm and using a picaxe to control a bunch of servo motors.

Anyways i was wondering what are the variable names for pins 2-5(picaxe 28x1) are? for programming purposes, for example variable "pin0" would be used for pin 11 on the data sheet.



thats the only question i have atm if i have more i know where to come anyways thanks

Welcome to the PICAXE forum Something.

for physical pins, please use the term "Leg" to help avoid confusion)


There are limited commands to use port A pins.
eg IF portA xxx THEN . . .

have a look at PICAXE Manual 1 page 83 and more specifically page 84
 
Last edited:
Top