pins command on M series

cachomachine

Senior Member
I wouls like to check if pin 0 is ON on a 20M and duplicate it on pin 1.
i have tried:

high 0
b0= pins &%00000001
if b0=1 then
high 1
endif

what is the correct way to do it?
 

hippy

Technical Support
Staff member
Are you trying to set pin 1 (B.1) to what is on input pin 0 (C.0) or trying to get it to follow output pin 0 (B.0) ?
 

cachomachine

Senior Member
If Isimulate this on both program editor, 1 never comes to 1

high 0
Do
If Pin0 = 1 then
High 1
Else
Low 1
End If
Loop
 

jims

Senior Member
This runs OK in the simulator for PE6 6.0.9.2....JimS
Code:
[color=Navy]#picaxe [/color][color=Black]20m2[/color]
[color=Blue]pause [/color][color=Navy]500   [/color][color=Green]'Pause to initialize system.[/color]

[color=Black]Main:

    [/color][color=Blue]Do
     If [/color][color=Purple]PinB.0 [/color][color=DarkCyan]= [/color][color=Navy]1 [/color][color=Blue]then
     High B.1
     Else 
      Low B.1
     End If 
    Loop
    [/color]
 

cachomachine

Senior Member
@technical
What i want to acheive is: when B.0 is 1, B.1 changes to 1 and when B.0=0, B.1 changes to 0, you are using C.0 to change B.1
 

Technical

Technical Support
Staff member
We were doing exactly what you stated you wanted to do in post #3 (react to input C.0). Post #14 and post #3 now say two very different things?....

Yes, i am trying to set pin 1 (B.1) to what is on input pin 0 (C.0)
If instead you want to react to output B.0, you must maintain a shadow (copy) register of the outputs yourself e.g. use variable b0 to keep a copy of the output states and then test bit0 to switch B.1 on and off.
On the M series chip there is no way to read what the current state of an output is. On the M2 series you can read outpinsB, but this does not work on the legacy M parts.

However if you have a spare input pin you could also just wire B.0 to the spare C.x input.
 
Top