Page 348 - Making things move_ DIY mechanisms for inventors, hobbyists, and artists
P. 348

Chapter 10    Projects     325




                     void left(int distance)
                     {
                       for(i=0;i< distance; i++) {
                         right_motor.step(-1);
                         left_motor.step(-1);
                         }
                     }

                     void right(int distance)
                     {
                       for(i=0;i< distance; i++) {
                         right_motor.step(1);
                         left_motor.step(1);
                         }
                     }

                     void upRight(int distance)
                     {
                       for(i=0;i< distance; i++) {
                         right_motor.step(2);
                         left_motor.step(-.2);
                         }
                     }
                     void upLeft(int distance)
                     {
                       for(i=0;i< distance; i++) {
                         right_motor.step(.2);
                         left_motor.step(-2);
                         }
                     }
                     void downRight(int distance)
                     {
                       for(i=0;i< distance; i++) {
                         right_motor.step(-.2);
                         left_motor.step(2);
                         }
                     }
                     void downLeft(int distance)
                     {
                       for(i=0;i< distance; i++) {
                         right_motor.step(-2);
                         left_motor.step(.2);
                         }
                     }
                24. Enjoy! Play with the photocells so you can interact with SADbot and make
                     interesting drawings.
   343   344   345   346   347   348   349   350   351   352   353