How to refresh hexbug?

If you remember, the hexbug will fall asleep after about five minutes of not-moving (this is another "smart" feature, we have to work-around). Five minutes is a long time; we can ask cron deamon to send some command to our toy each (for example) four minutes (possibly you can adjust the period for your species). The crontab line will look like:

*/4 * * * * command-to-be-executed

Command can be anywhere, because we should specify the full path. Even this, I would reccomend /usr/local/bin/ directory.

This bash script should send a command by setting any control line to zero, for example the lowest bit:

/usr/local/bin/parashell 0x378 0xFE

... but it cannot stay set permanently. For one second wait, we can use command:

sleep 1s

Then we can reset all control back:

/usr/local/bin/parashell 0x378 0xFF

Another problem is, if nobody will use your toy, it will end at one of the walls. Good solution is to change forward-backward direction regularly. Correct solution would be to set up the cron correctly, less complicated is to use a random variable to set direction - we have to use the if command; in the bash, it could look like:

if [ $RANDOM -lt 16333 ];

then

/usr/local/bin/parashell 0x378 0xFE

else

/usr/local/bin/parashell 0x378 0xFD

fi

sleep 1

/usr/local/bin/parashell 0x378 0xFF

Comment: $RANDOM looks as a system variable, but this is a function, which generates random numbers from 0 to 32767. Half of the interval is 16383, but from my testing, it tends to lower values. The text "-lt", "-gt" is used in the bash instedead of < or > respectively, because this symbols in script mean redirection. fi means end of if part. You can add a comment into file, comment lines start with the # symbol.

Note: If any user leave this experiment with an arrow activated, the hexbug will try to walk (against wall, useally), till this refresh will be executed. This is a good reason to set it to one minute interval. User cannot detect it, because nobody nows, if anybody else is trying this page from another computer. Another solution is to execute the command "/usr/local/bin/parashell 0x378 0xFF" directly from crontab every minute (before this refresh).