Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. // Jarod_project_3
  2. // sensor config --- Ultrasonic = UltraSonicEyes -- S1
  3. // sesnor config --- Color = LightEyes -- S2
  4.  
  5. void data_storage_setup();
  6. void store_data();
  7.  
  8. long Count = 0; // Keeps track of how many pieces of data we have
  9.  
  10. task main()
  11. {
  12. data_storage_setup();
  13. for (initializer; argument; incrementer) {
  14. store_data();
  15. // Do robot run code inside this loop
  16. // sleep(30); // data sampling rate
  17. }
  18. // Make sure you close the file properly
  19. datalogClose();
  20. }
  21.  
  22. void data_storage_setup() {
  23. // The first argument is a datalog index number.
  24. // The filename will be saved in the rc-data folder as
  25. // datalog-<INDEX>.txt
  26. // The format is a comma separated value file.
  27. // The 2nd argument is the number of columns you wish to have in the file
  28. // The 3rd argument specifies if you wish to append to the datalog, if it
  29. // exists.
  30. datalogFlush();
  31. datalogClose();
  32. if (!datalogOpen(10, 4, false)) {
  33. displayCenteredTextLine(4, "Unable to open datalog")
  34. while (true) { sleep(1); }
  35. }
  36. }
  37.  
  38. void store_data() {
  39. // You can add an entry at the specified column numbers
  40. // The commented out datalogAdds are different types
  41. datalogAddChar(0, SensorValue[S2]); // Put the sensorvalue 2 inside the first column
  42. // datalogAddShort(1, 8000 + i); You only want sensor values not calculated values
  43. // datalogAddLong(2, 23838 + i);
  44. // datalogAddFloat(3, 678.98 / (i + 1));
  45. Count++; // Increments count so we know how much data we've collected
  46. }
  47.  
  48. // robot -> lego brick -> file management utility
  49. // Download file, change extension to csv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement