6 Tips for Writing Code

By Gareth Branwyn. Posted

This article was originally published as part of HackSpace magazine, which has since been incorporated into Raspberry Pi Official Magazine.

6 Tips for Writing Code

In a highly recommended YouTube video and Instructable, entitled ‘Arduino Sample Code Mashups’, Becky Stern simply and beautifully breaks down how to think through the design of a hardware project and the software that you will need to create to run it.

While the video is geared to Arduino, almost everything is applicable to any microcontroller programming language. Here are the basic considerations that she outlines:

  1. Define your purpose – Write down the goals of your project, and what features are required and which ones are optional.
  2. Classify inputs and outputs – List out all of the inputs and outputs you plan on using.
  3. Write pseudocode – Explain in plain English the steps the program will walk through as it's executed.
  4. Test your hardware – Test out each subsystem of your design by using sample code known to work with each input and output component.
  5. Create your program – Paste in all of your now-verified code samples, and start building your program from there.
  6. Make incremental improvements – Once you get everything working, you can then fix or change any issues you encounter or changes you care to make.

Gareth Branwyn

Gareth has been a lifelong practitioner (and chronicler) of DIY tech, media, and culture. He is the author of ten books, including Tips and Tales from the Workshop, and is a former editor for Boing Boing and Wired

From Raspberry Pi Official Magazine store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.