Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by Sascha ( 15 years ago )
task main()
{
 int g[27]; //Messreihen
 long y[10]; //zu je 10 Mittelwerten
 long ym10, sigma10;
 byte hg, hy, hym10, hsigma10;
 int i=0, j=0;
 string str;
 
 // Lichtsensor initialisieren
 SetSensorType(S2, SENSOR_TYPE_LIGHT_ACTIVE);
 SetSensorMode(S2, SENSOR_MODE_RAW);

 // Files l¨oschen und anlegen
 DeleteFile("g.txt"); CreateFile("g.txt",300,hg);
 ...

 // Grauwerte initialisieren g=[0,10,20,...,250,255];
 while(i<26) 
 {
  g[i]=i*10;
  i=i+1;
 }

 g[26]=255;
 

 i=0;
 while(i<27) 
  {
  ClearScreen();
  str=NumToStr(g[i]);
  str=StrCat("Grauwert ",str);
  TextOut(0, LCD_LINE1, str);
  Wait(5000);
  j=0;

  while(j<10) 
   {
    y[j]=SENSOR_2;
    Wait(20);
    j=j+1;
   }
  
  j=0;
  ym10=0;
  while(j<10) 
   {
    ym10=ym10+y[j];   
   }

  ym10=10.0/10.0*ym10;

  j=0;
  sigma10=0;
  while(j<10) 
   { 
    sigma10=sigma10+(10*y[j]-ym10)*(10*y[j]-ym10)
   }
  sigma10=sigma10/9;
  sigma10=Sqrt(sigma10);
  
  PlayTone(450, 50);
  
  ClearScreen();

  str=NumToStr(g[i]);
  WriteLn(hg, str);
  TextOut(0, LCD_LINE1, str);
  str=NumToStr(ym10);
  TextOut(0, LCD_LINE2, str);
  str=NumToStr(sigma10);
  TextOut(0, LCD_LINE3, str);

  Wait(1000); // Wartezeit Anzeige der Werte
  i=i+1;
 }
}

 

Revise this Paste

Your Name: Code Language: