BASIC programming Questions

I am very new to this BASIC programming, I have been dealing a little with C programming language before.

I am currently playing with BH3-R and I have generated an ‘autonomous’ running program for my robot with the use of Powerpod.

I have manage to change YSpeed to 0 and XSpeed to 120, thus the robot is able to walk straight now.

But

My question is :
1)How can I make my robot walk with different speed for a particular amount of time then change speed for a different amount of time again?

For example,I want to make the robot to run at say XSpeed of 20 for 10seconds initially, then XSpeed of 120 for 5 seconds following that.

I have been experimenting with the use counters for a couple of days, but due to my inability to fully understand everything in the generated program, my experimentation leads me nowhere. Hope to get some directions from some experts here.

Images attached are my where I have edited my program. I have first initilized the variable ‘a’, then do the calculation of the counter where ‘a=a*2’, then set the conditions at ‘Shunt’.

2)Also, from the generated program, is ‘Shunt’ considered as the ‘Main’ program ? As it would have been depicted in C programming language ? Although there’s a ‘main’ loop above ‘Shunt’, but that’s too short(2 lines) for a ‘main’ loop, isn’t it ?

Cheers.



Hello can anybody help me ? It is rather simple question only.

It might help if you were to post the entire code, rather than just 3 screenshots.

Also, what is the robot currently doing with the changes that you have made? I’m guessing it moves forward slowly?

Hi yes it is just walking slowly. The speed of the robot is adjusted from XSpeed.

Attached is the whole code.
autonomous.bas (24.2 KB)

Your problem, as far as I can tell, is that the a variable doesn’t stay below 10 for long enough. Try increasing 10 to 1000 or so and see what happens. It should walk quickly for a short time and then slow down.

Hi its working now! I changed from a=a*2 to a=a+2 and it got what i want now :slight_smile:

i wonder why though.

Um… Because (Assuming you also increased 10 to 1000):

a=a*2= 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024. 10 cycles until switch to other speed.a=a+2= 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, etc. ~500 cycles until switch to other speed.

with a=a*2 it should change speed faster. but it does not change at all.
with a=a+2 it will change speed after some time.

Actually, it does change speed. The robot moving slowly happens AFTER the value goes above 10. That happens so fast that it is almost impossible to notice it moving faster.