Combining Arduino Sketches

Beginners love Arduino coding because there is so much of it available to just copy, load and go without too much thinking required.

Then they find that one thing they want to do is in one sketch and another in a second sketch. All they need to do is combine these sketches! This can be a big hurdle the first time it happens and many fail to get a satisfactorily working product.

There is a systematic approach to this that helps to ensure that things work.

Continue reading “Combining Arduino Sketches”
Advertisements

Finite State Machine Programming Basics – Part 2

The first part of this article introduced a simple Finite State Machine through the exercise of transforming the standard linearly programmed Blink example into a FSM style application.

In this part we’ll look at other common embedded applications and how they can be coded using FSM techniques.

Continue reading “Finite State Machine Programming Basics – Part 2”

Finite State Machine Programming Basics – Part 1

Many beginner programmers, once they go beyond the ‘blinking LED’ code, get blocked by not being able to do more than one thing at once. In many cases they are directed to the ‘Blink WithOut Delay’ code (BWOD) as a hint about what to do, but this soon also runs out of steam. BWOD implies, but does not make explicit, a Finite State Machines (FSM) approach.

In this article we’ll evolve the simple linear Blinking LED sketch into a FSM to illustrate the difference in approach.

Continue reading “Finite State Machine Programming Basics – Part 1”

YX5300 MP3 Player

The YX5300 MP3 module is easily interfaced to a microcontroller, creating MP3 player with a user interface. Using the MD_YX5300 library and an understanding of how the device works (see the previous posts here and here), this article describes the code for a simple MP3 player and a more complex player with an LCD module display.

Continue reading “YX5300 MP3 Player”

YX5300 Serial MP3 Player – Message Sequencing

Since my previous YX5300 post I have received a number of questions related to how the serial messages between a host and the MP3 module work. Understanding this message flow is important when writing code that uses the MP3 player in an interactive application.

Continue reading “YX5300 Serial MP3 Player – Message Sequencing”

Persisting Application Parameters in EEPROM

When an application starts, any data was was part of a previous execution is reset to the initialised values of the variables. Often, however, it is desirable to maintain configuration and state values between processor resets. EEPROM is a good option to store these values.

This article explores ways to make this task easy.

Continue reading “Persisting Application Parameters in EEPROM”

Are Strings really that Evil?

One of the many repeating themes on the Arduino forums is the use of Strings (with a capital ‘S’) against usings strings (with a little ‘s’) – the former refers to a class that encapsulates string handling and the latter refers to the use of nul terminated char arrays.

The kind of forum threads involved are generally someone who wants to use Strings and is having a problem followed by a lot of other posts telling them not to because they are ‘bad’.

So what makes them ‘bad’ and is this really a problem?

Continue reading “Are Strings really that Evil?”

Fun and Games, and a New Library

F+G_Icon

I have for some time wanted to (re)write some of the computer games from my younger days as an exercise in programming and for a bit of fun. I recently decided to do this on a very low-res display made from individual LED matrix modules and in the process created a new library to manage the LED panel display.

Continue reading “Fun and Games, and a New Library”

Playing MIDI files on Arduino – Part 3 Hardware and MD_MIDIFile Library

MIDI_computer_music

Part 1 and part 2 covered Standard MIDI Files and playing music at the right tempo. Once we have a MIDI stream, we need hardware that can play the notes.

In this part we’ll look at how to finally make a sound and how the MD_MIDIFile library supports this in software.

Continue reading “Playing MIDI files on Arduino – Part 3 Hardware and MD_MIDIFile Library”

Playing MIDI files on Arduino – Part 2 Keeping to the Beat

MIDI_computer_music

Keeping time in music is very important. So it stands to reason that MIDI files include a number of parameters related to keeping time, and the MIDI standard also includes time synchronization messages to ensure that all the instruments keep to the same musical beat.

Part 1 covered the content of Standard MIDI Files. In this part we’ll look at the how to  keep the music synchronised to the beat, one of the more complex parts of playing a SMF.

Continue reading “Playing MIDI files on Arduino – Part 2 Keeping to the Beat”