Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Jarod_project_3
- // sensor config --- Ultrasonic = UltraSonicEyes -- S1
- // sesnor config --- Color = LightEyes -- S2
- void data_storage_setup();
- void store_data();
- long Count = 0; // Keeps track of how many pieces of data we have
- task main()
- {
- data_storage_setup();
- for (initializer; argument; incrementer) {
- store_data();
- // Do robot run code inside this loop
- // sleep(30); // data sampling rate
- }
- // Make sure you close the file properly
- datalogClose();
- }
- void data_storage_setup() {
- // The first argument is a datalog index number.
- // The filename will be saved in the rc-data folder as
- // datalog-<INDEX>.txt
- // The format is a comma separated value file.
- // The 2nd argument is the number of columns you wish to have in the file
- // The 3rd argument specifies if you wish to append to the datalog, if it
- // exists.
- datalogFlush();
- datalogClose();
- if (!datalogOpen(10, 4, false)) {
- displayCenteredTextLine(4, "Unable to open datalog")
- while (true) { sleep(1); }
- }
- }
- void store_data() {
- // You can add an entry at the specified column numbers
- // The commented out datalogAdds are different types
- datalogAddChar(0, SensorValue[S2]); // Put the sensorvalue 2 inside the first column
- // datalogAddShort(1, 8000 + i); You only want sensor values not calculated values
- // datalogAddLong(2, 23838 + i);
- // datalogAddFloat(3, 678.98 / (i + 1));
- Count++; // Increments count so we know how much data we've collected
- }
- // robot -> lego brick -> file management utility
- // Download file, change extension to csv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement