C   27

array-move.c

Guest on 15th January 2022 09:19:50 AM

  1. /* * * * *
  2.  * array-move.c
  3.  *
  4.  * Make the Scribbler move in different speeds and times by putting different numbers to different
  5.  * arrays and giving them as parameters to the commands rForward and rTurn.
  6.  *
  7.  * Authors: Dilan Ustek, Erik Opavsky
  8.  *
  9.  *
  10.  */
  11.  
  12.  
  13. #include "MyroC.h"
  14.  
  15. int
  16. main()
  17. {
  18.  
  19.   rConnect("/dev/rfcomm0");
  20.   rSetForwardnessTxt("fluke-forward");
  21.  
  22.   int numMoves = 8; // the number of moves that the Scribbler will do.
  23.   int i;
  24.  
  25.   // the various speeds and times in two seperate arrays
  26.  
  27.   double speed[] = {.3, .2, .4, 1, 1, .3, .2, .5};
  28.  
  29.   double time[] = {.3, 1, .6, .1, 1, .9, .3, .8};
  30.  
  31.   // go forward and turn for the various speeds and times given by the two arrays
  32.   for (i = 0; i < numMoves; i++)
  33.     {
  34.       rForward (speed[i], time[i]);
  35.       rTurn (speed[i], time[i]);
  36.     }
  37.  
  38.   // beep when done
  39.   rBeep (1, 500);
  40.  
  41.   rDisconnect();
  42.  
  43.   return 0;
  44. } // main

Raw Paste


Login or Register to edit or fork this paste. It's free.