Crossing the Finish Line Faster: Leveraging Cody to Implement GPS Data Logging

Charles Goode

This is a guest blog post from our community. Join our Discord to meet the author and connect with other developers passionate about Code Search and AI!

Hello, my name is Charles Goode and I’m an electrical engineering major at Kennesaw State University. I’m here to tell you about Kennesaw Motorsports and to walk you through how I completed my first project on the team with the help of Cody.

Kennesaw Motorsports

Kennesaw Motorsports is a college competition team where students from various majors come together with one mission: to build race cars. Each year, we build two formula-style vehicles to compete in a competition held by the Society of Automotive Engineers, known as Formula SAE. Each team is evaluated by industry professionals on presentation, design, cost, and performance to give future engineers the experience they can’t get in the classroom.

My First Project with Cody

I will walk you through how Cody helped me complete my first project on the team. Going into this project, I needed more experience writing code and messing with microcontrollers and electronics. Despite my situation, I was able to complete my project quickly with the help of Cody.

The project aims to implement a GPS data logger in our race car. We collect a ridiculous amount of data throughout our system, and the ability to plot the position of our car as it goes around a track can help us perform much better data analysis.

Hardware Involved

First, I start with the Teensy and the GPS. Before I mess with the Micro SD card or get into plotting, I want to make sure the GPS will work correctly.

For prototyping, I am using a breadboard and jumper wires. Below, you'll find the layout of the hardware and wiring instructions.

  • 3V to Vin (3V on Teensy to GPS VIN)
  • GND to GND
  • TX to RX (Pin 8 on Teensy to GPS RX)
  • RX to TX (Pin 7 on Teensy to GPS TX)

Now everything is wired up correctly, I can ask Cody to write some code for my project.

Prompt: Write me some basic code for using an Adafruit Ultimate GPS with a Teensy 4.0

Cody quickly delivers, and the code runs perfectly once I install the necessary library. As you can see, the serial monitor is now printing the coordinates and letting me know the date, time, and satellite information.

Now that we have our microcontroller and GPS working together, we can add the microSD breakout board. This will allow us to print the data from the GPS in a .CSV file for further analysis.

Here is the updated hardware layout and additional wiring instructions.

  • SCK to CLK (Pin 13 on Teensy to microSD CLK)
  • MISO to DO (Pin 12 on Teensy to microSD DO)
  • MOSI to DI (Pin 11 on Teensy to microSD DI)
  • CS to CS (Pin 10 on Teensy to microSD CS)

Now that everything is wired up correctly, I can ask Cody for additional code. This time, I mentioned the microSD breakout board and specifically asked only to send the GPS coordinates to the CSV file.

Prompt: Open a CSV file on the SD card and print the GPS coordinates

Cody quickly tells me which libraries I need and completely rewrites the code to fit my specifications. Once I upload this, the coordinates begin printing without the unnecessary information from before.

I will now plug the Micro SD card into my computer to confirm it opened the file and correctly formatted the coordinates.

All the data is formatted correctly, but we need some real data to plot this correctly. The next time we tested one of our cars, I collected some real data from the CSV file. Now that we have the data needed, we must visualize it. There are a few ways to do this, but I picked MATLAB. I cannot do this inside my IDE, but Cody can still be helpful.

I asked Cody for a MATLAB script, and it was quickly delivered. I went to MATLAB, pasted in the script, and it ran perfectly. Once I input the data from our testing day, it plotted it. Here is the data visualized using the plot function.

As you can see, Cody was able to help me complete my first project quickly.

Favorite command

Cody has many features, but one of the most important features for people trying to learn is the “Explain Code” command.

With the “Explain Code” command, Cody quickly gives me an in-depth explanation of the code. I am trying to learn from this project, so understanding the code is essential.

Within seconds of my command, Cody gives me an in-depth explanation of how the entire program functions. With this information, I can see exactly how the outcome is achieved and can return to this chat to help me complete similar functions in my next project.

Conclusion

A major key to being successful as a team or as a company is making meaningful relationships, and we are thankful to have one with Sourcegraph. We are always looking for ways to grow as a team, and receiving support from a fast-growing company in the Software and AI industry is a major leap in the right direction—big thanks to the team at Sourcegraph for supporting our journey towards innovation and success.

To learn more about Kennesaw Motorsports, visit our website here!


Cody can help you code faster, improve your productivity, and unlock new knowledge. Give Cody a try today!

Get Cody, the AI coding assistant

Cody makes it easy to write, fix, and maintain code.