Trying to reset a var!

Man_in_uk

New Member
Hi All.
Sorry my first post is not is so pathetic but I am having trouble in resetting a Var value back to zero.

I am using the flow chart method to get this test code

main:
let dirsC = 1

Cell_7_8:
write varA, 0
Cell_7_12:
if pinC.3=0 then

goto Cell_10_12
end if
stop
Cell_10_12:
inc varA
if varA >= 5 then
goto Cell_7_8
end if
goto Cell_7_12

The count up loop runs through Cell_7_12 adding 1 to VarA each time. When the count gets to =>5 it then runs back to Cell_7_8 where I am trying to reset VarA back to zero using the write command.
No matter what I try, I cannot get VarA back to zero.

Please can anyone let me know where I am going wrong?
 

hippy

Technical Support
Staff member
Welcome to the PICAXE forum.

You don't want to use a WRITE command; to reset a variable you need an EXPRESSION command from the VARIABLES section of the toolbox.

For the EXPRESSION command; set the "let variable=" field to "varA" and the "Value1" field to 0 (zero), leave the rest blank, then click OK.
 

hippy

Technical Support
Staff member
Life is good again.
Excellent. And if you do get stuck or need anything else clarifying please do feel free to ask. Members here are always willing to help and advise when they can and helping make life good again is always a satisfying outcome.
 

Man_in_uk

New Member
Thanks hippy.
Rather than waste a new thread on my new beginnings, I do have another ... possibly easy question.

I am trying to setup a routing that reads serial in from another chip and puts the value in VarA. My flow chart is based on an example in the manual 'using the serin command to receive serial data', but I am having no luck.

Using an 18M I have the main thread flashing an LED so I can see that the program is running. (when sent to the chip, this part works)
My second thread is just the 'start' box followed by the 'serin' box. The arrow loops back so it is constantly looking for serial data. (when this second thread is added, the program does not run)

I cannot tell if my problem is with the 'serin' command, or trying to run multiple threads.
(If anyone can point me to a working example, it would help ... possibly)
 

rossko57

Senior Member
Serin will normally sit and wait for data forever. What is your data source, have you paid attention to baud rate and polarity?
 

Man_in_uk

New Member
I think I have two problems.
Serin, is waiting forever for data and as it is not getting any .... all threads are stopped. I need the other threads to carry on, even if there is no data coming in.

The data source is 40x2 running a simple serout loop every few seconds. I have tried a few different output pins with no success but I have yet to discover if I need any resistors in the circuit. I have not yet stumbled over any sample schematic or flow chart examples.
(I know I should not be using flow charts but that is what swayed me in the Picaxe direction,)
 
Top