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.
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.
Ask an Engineer – exclusive advice from the brains behind Raspberry Pi
While the video is geared to Arduino, almost everything is applicable to any microcontroller programming language. Here are the basic considerations that she outlines:
- Define your purpose – Write down the goals of your project, and what features are required and which ones are optional.
- Classify inputs and outputs – List out all of the inputs and outputs you plan on using.
- Write pseudocode – Explain in plain English the steps the program will walk through as it's executed.
- Test your hardware – Test out each subsystem of your design by using sample code known to work with each input and output component.
- Create your program – Paste in all of your now-verified code samples, and start building your program from there.
- 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 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
Subscribe to Raspberry Pi Official Magazine
Save up to 37% off the cover price and get a FREE Raspberry Pi Pico 2 W with a subscription to Raspberry Pi Official Magazine.
More articles
Ask an Engineer in Raspberry Pi Official Magazine issue 172
It’s not just our engineers who are building things: Kat Shann, documentation specialist at Raspberry Pi, has built an intriguing way to commune with the spirit world via a Raspberry Pi-controlled ouija board. Inspired by the cyber-pet craze of the 1990s, Tara Carter has built her own, using a Raspberry Pi Zero 2 W to […]
Read more →
Win a CrowView Note & Raspberry Pi 5
Portable Raspberry Pi computing
Read more →
Raspberry Pi Cinema Camera
As in, it’s a cinema-grade quality camera. Created by menggu
Read more →