I’m trying to use the original timer code from the first thread in a simple dead reckoning pattern. My code has the time calculator directly after the SERIN, has 2 lines of code changing the wheel numbers for the SEROUT, then the SEROUT. It loops this until realtime = whatever time I want. It goes forward, turns right, forward, right, forward, right, then forward. The problem is that after the first forward (Which works perfectly), it just turns right until I turn off the robot. Any ideas why? The variables are the same as the default, delta_t is declared and set to 1 in intilization. The forums aren’t being nice and the SERINs are all on one line in the actual code.

```
do
Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
time = time + delta_t + 1
if time > 38 then
time = time - 38
realtime = realtime + 1
endif
p1_y = 254
p2_y = 254
Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
127,127,127,127]
loop until realtime = 2
do
Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
p1_y = 254
p2_y = 0
time = time + delta_t + 1
if time > 38 then
time = time - 38
realtime = realtime + 1
endif
Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
127,127,127,127]
loop until realtime = 1
do
Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
time = time + delta_t + 1
if time > 38 then
time = time - 38
realtime = realtime + 1
endif
p1_y = 254
p2_y = 254
Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
127,127,127,127]
loop until realtime = 2
do
Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
p1_y = 254
p2_y = 0
time = time + delta_t + 1
if time > 38 then
time = time - 38
realtime = realtime + 1
endif
Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
127,127,127,127]
loop until realtime = 1
do
Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
time = time + delta_t + 1
if time > 38 then
time = time - 38
realtime = realtime + 1
endif
p1_y = 254
p2_y = 254
Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
127,127,127,127]
loop until realtime = 2
do
Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
p1_y = 254
p2_y = 0
time = time + delta_t + 1
if time > 38 then
time = time - 38
realtime = realtime + 1
endif
Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
127,127,127,127]
loop until realtime = 1
do
Serin COMA\COMB, INBAUD, [oi_swA,oi_swB,rc_swA,rc_swB,p2_x,p1_x,p4_x,p3_x,PB_mode,packet_num,p2_y,p1_y,p4_y,p3_y,p2_wheel,p1_wheel,p4_wheel,p3_wheel]
time = time + delta_t + 1
if time > 38 then
time = time - 38
realtime = realtime + 1
endif
p1_y = 254
p2_y = 254
Serout USERCPU, OUTBAUD, [255,255,p1_y,0,p2_y,0,127,127,127,127,127,127,
127,127,127,127]
loop until realtime = 2
```