For the random tones, it really only requires four parts:
■ FIGURE 3.
• Small Speaker
• 1K Resistor
• BC547 NPN Transistor
• 100 ohm Resistor
Most electronic hobbyists will have these things laying around.
The schematic (Figure 3) has all the values for each part.
We are generating a lot of random numbers, so they
are put into variables Rnd0 to Rnd7. I know that we can
avoid a lot of the variables through smart programming,
but I have a tendency to keep things understandable. After
all, I’ve been programming a long time, and the variables
in my 72 year old brain are slowly disappearing, so keep it
simple; we have a lot of young brains to teach.
Next, we come to the notes in a sequence section. In
this section are a bunch of notes that we can use to play
with. First, we have notes from C3 to A4 which is about
midrange on a piano:
int sequence =
follow what I did.
However, let’s go to the program to see how it does
all this. Load the Arduino sketch One_Over_F_Random_
Numbers.ino or view the One_Over_F_Random_
This is the sequence we use first. It allows you to hear
what 1/f music is like. Then, you can try different scales or
create different note sequences for yourself.
Numbers.txt file at the article link.
As in all Arduino programs, we have various sections.
The first section in this one describes the circuit diagram.
The Arduino circuit diagram can be seen in Figure 3. I
chose an Arduino Uno, but almost any Arduino can be
used. By changing the resistor in the speaker circuit (R2),
the volume can be changed a bit.
All the notes are listed in the note_table.h file. It’s
added to the Arduino program by clicking Sketch, Add
The sequence is an array. The three 1s at the
beginning are there because when we add up three dice
with ones being thrown, we come up with the number 3.
When you access an array, it always starts at 0, so we
have to start our notes at the fourth position, or 3. The 1s
at the end are for rests or no notes played. 1/f notes will
have a tendency to hang around the middle of the
sequence, so rests aren’t often played; after all, you don’t
want to hear too many nothings.
File. The note values can then be compiled into the
program by the #include “note_table.h” line. If you look at
the note table, the notes are labeled like NA1 for example.
As you go on with trying out other sequences,
comment the first sequence and then uncomment the
sequence you want to try. For instance, notes in the
pentatonic scale are oriental in nature.
The N was added because A1 is an Arduino word
representing the analog pin 1 and will produce a syntax
error. All notes, therefore, are prepended with an N.
The next section sets up the variables in the program.
In order to determine the lengths of notes, we have to
decide on what tempo we want the notes to play at. The
If you want to go farther in trying out different
programming techniques — such as making the array
smaller — then put the size of the array in the random
function. We can determine the length of the sequence
array, lenSeq, by using the Arduino function sizeof(). Sizeof
120 beats per minute. This gives us the length of a quarter
note (Q in the program). From there, we can use simple
math to determine the lengths of the other common notes:
sixteenth (S), eighth (E), and whole (W). If you want to play
things slower or faster, this is the number to change.
Wikipedia link to the KIM-1 computer
Wikipedia link to the TRS-80 computer
Wikipedia link to the IBM Selectric typewriter
Link to the Scientifc American website
32 May 2016