H HAZELEB Member Mar 24, 2008 #1 Hi, How do I assign a variable to a portc pin b0 = portc pin0 gives a syntax error in this line, any help appreciated Ted.
Hi, How do I assign a variable to a portc pin b0 = portc pin0 gives a syntax error in this line, any help appreciated Ted.
T testerrrs New Member Mar 24, 2008 #2 Code: if portc pin0 = 1 then let b0 = 1 else let b0 = 0 endif Jon
H HAZELEB Member Mar 24, 2008 #3 Hi, what I want is to preload portc pin0 into a variable to serout to xbee It works for b3 = pin but not for b3 = portc pin why. #picaxe40x1 init: high 7 pause 100 main: readadc 0,b0 readtemp 1,b1 b2 = pin2 b3 = pin6 b4 = portc pin0 serout 7,t2400, ($55,$55,b0,b1,b2,b3,b4) pause 1000 goto main
Hi, what I want is to preload portc pin0 into a variable to serout to xbee It works for b3 = pin but not for b3 = portc pin why. #picaxe40x1 init: high 7 pause 100 main: readadc 0,b0 readtemp 1,b1 b2 = pin2 b3 = pin6 b4 = portc pin0 serout 7,t2400, ($55,$55,b0,b1,b2,b3,b4) pause 1000 goto main
hippy Ex-Staff (retired) Mar 24, 2008 #4 "b3 = portc pin" isn't supported by the PICAXE language, but you should be able to achieve "b0 = portc pins" using "Peek $07,b0". That will put the entire input port into b0, individual bits of b0 can then be referenced using the bit0 to bit7 variables ... Code: Do Peek $7,b0 SerTxd("PortC Input = %",#bit7,#bit6,#bit5,#bit4,#bit3,#bit2,#bit1,#bit0," ",#b0,CR,LF) Pause 500 Loop To perform the "b4 = portc pin0" you're after you can do that with bit masking ... - Peek $07,b4 : b4 = b4 & %00000001 To get at other bits is a bit more complicated, this would achieve "b4 = portc pin1" ... - Peek $07,b4 : b4 = b4 & %00000010 MAX 1
"b3 = portc pin" isn't supported by the PICAXE language, but you should be able to achieve "b0 = portc pins" using "Peek $07,b0". That will put the entire input port into b0, individual bits of b0 can then be referenced using the bit0 to bit7 variables ... Code: Do Peek $7,b0 SerTxd("PortC Input = %",#bit7,#bit6,#bit5,#bit4,#bit3,#bit2,#bit1,#bit0," ",#b0,CR,LF) Pause 500 Loop To perform the "b4 = portc pin0" you're after you can do that with bit masking ... - Peek $07,b4 : b4 = b4 & %00000001 To get at other bits is a bit more complicated, this would achieve "b4 = portc pin1" ... - Peek $07,b4 : b4 = b4 & %00000010 MAX 1