Antoinette J. Citizen

Black Box: On the tram

Posted in Arduino, Black Box, LCD, Sensors by antoinettejcitizen on 03/23/2011

I have hook up my GPS module to my Black box prototype.  For this I wanted to calculate the distance travelled. So I am using a gps distance calculation example, which calculates the distance between two longitude/latitude points. Code only had to be modified slightly to update the waypoint to be measured against and accumulate the total distance travelled. I took it for a tram ride. It works… As it calculates the distance between waypoints, it is more accurate the more often it updates. This code below is programmed to update every 1/4 of a sec, but mine does not get close to that. 1-5minutes seems standard. I will have to look into how to get steadier updates.

GPS distance pde

So currently it is using the four lines on the LCD to display- Time in existence, kilometres travelled, percent of the time it has been in a certain position and an interactions count. I have been working on storing these variables and data logging all collected info to SD. It took a while to get it’s memory working. Writing to SD was simple. But reading this info back and turning into meaningful data was a bit more complex (well for me it was). You need read the data back into a string and then convert string to a char array turn the array into a float/long etc… or maybe you could just read the info back into a char array. hmmm.

My new favourite friends are:

atol  and atof

long stringToLong(String s)
char arr[12];
s.toCharArray(arr, sizeof(arr));
return atol(arr);

The box is looking a bit worse for wear, but I wired up a shield for everything yesterday. So it is good to go. Will be making the actual box next week.

%d bloggers like this: