Stamp to Picaxe code

tmack

Member
Can anyone help me translate this?

relay var b3 'relay number storage variable
stat var b4 'relay status ON/OFF variable
baud con 16468 '9600,N,8,1
serpin con 0 'serial I/O pin = 0

loop:
serin serpin,baud,[wait(254),relay,stat] 'serial data in on pin0
if relay = 1 then outr1 ' if request is for relay#1 then goto relay#1 routine
if relay = 2 then outr2 ' if request is for relay#2 then goto relay#2 routine
if relay = 3 then outr3 ' if request is for relay#3 then goto relay#3 routine
if relay = 4 then outr4 ' if request is for relay#4 then goto relay#4 routine
goto loop

outr1:
if stat = 1 then high1 ' If status request is I/O pin#1 logic 1 [high]
low 1: goto loop ' then make I/O pin#1 high, else make it [low]

high1:
high 1: goto loop ' Make I/O pin#1 logic 1 [High]

outr2:
if stat = 1 then high2
low 2: goto loop

high2:
high 2: goto loop

outr3:
if stat = 1 then high3
low 3: goto loop

high3:
high 3: goto loop

outr4:
if stat = 1 then high4
low 4: goto loop

high4:
high 4: goto loop
 

hippy

Technical Support
Staff member
Answer : Probably.

The 'x VAR y' and 'x CON y' change to 'SYMBOL x = y'

You'd however need to change the baud which is 9600 to N4800 or T4800, and then run the PICAXE at 8MHz using 'SETFREQ M8'

The 'serin serpin,baud,[wait(254),relay,stat]' changes to 'SERIN serpin,baud,relay,stat' but there's no way to add a wait delay with a PICAXE SERIN. If it's actually waiting for a byte value of 254 then it would be 'SERIN serpin,baud,(254),relay,stat'
 

andrew_qld

Senior Member
Also, I'm not sure if you can use "high1:" etc as a label. I could be wrong, but using commands as labels tends to upset things.
 
Top