SHARE
TWEET

Untitled

a guest Dec 3rd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void Drive(int speed){
  2.   OnFwd(OUT_A, speed);
  3.   OnFwd(OUT_B, speed);
  4. }
  5.  
  6. void Print(unsigned int data[])
  7. {
  8.   NumOut(0,0,data[2]);
  9.   NumOut(0,20,data[1]);
  10.   NumOut(0,40,data[0]);
  11.   TextOut(0,60,"RAW");
  12. }
  13.  
  14. int GetGreyScale(unsigned int rawData[])
  15. {
  16.    int sum = rawData[0] + rawData[1] + rawData[2];
  17.    return sum/3;
  18. }
  19.  
  20. int ReadEx(const byte port, unsigned int rawData[], unsigned int normData[], int scaledData[], int cval){
  21.   ClearScreen();
  22.   int resultRaw = ReadSensorColorEx(port, cval, rawData, normData, scaledData);
  23.   return GetGreyScale(rawData);
  24. }
  25.  
  26. int CountLines(int resultArr[]){
  27.     int lines = 0;
  28.    
  29.     for(int i=0; i<480; i++){
  30.          if(resultArr[i] > resultArr[i+1]){
  31.                if(resultArr[i+1] < resultArr[i+2]){
  32.                            lines++;
  33.                }
  34.          }
  35.     }
  36.      return lines;
  37. }
  38.  
  39. task main()
  40. {
  41.  SetSensorColorFull(S1);
  42.  short fileSize;
  43.  int lineNumber = 0;
  44.  byte fileHandle;
  45.  short bytesWritten;
  46.  unsigned int rawData[], normData[];
  47.  int scaledData[], cval;
  48.  
  49.  int x= ReadEx(S1, rawData, normData, scaledData, cval);
  50.  Wait(15);
  51.  
  52.  int y=ReadEx(S1, rawData, normData, scaledData, cval);
  53.  Wait(15);
  54.  
  55.  int z=0;
  56.  int counter = 0;
  57.  
  58.  RotateMotor(OUT_A, 15,250);
  59.  for (int i = 0; i < 40 ; i++)
  60.  {
  61.   z = ReadEx(S1, rawData, normData, scaledData, cval);
  62.  
  63.   if(x > y && y < z){
  64.        counter++;
  65.   }
  66.  
  67.   Wait(10);
  68.  
  69.   x = y;
  70.   y = z;
  71.  }
  72.  ClearScreen();
  73.  NumOut(0,0,counter);
  74.  Wait(5000);
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top