The aim for this exercise is to generate an upwards-ramping sawtooth wave that can be tuned to (roughly) musical pitches. The amplitude of the wave is constant. The resulting generator has 64 different pitches selected by the first 6 bits of a DIP switch. 0000 is roughly equal to MIDI note C0 and %111111 is roughly equal to MIDI note D#5.
The waveform is made up of 32 steps. Each step is output from the Arduino board via digital outputs 2 to 7 and then into a R2R ladder. Output 2 is the lsb whilst output 7 is the msb.
The command "delayMicroseconds" is then used in the Arduino program loop to actualise this delay in every step of the waveform. The DIP switch is connected to digital pins 8 to 13 and selects as a binary value the pitch MIDI number. The corresponding delay time is looked up in an array of 64 integers.
You can view an image of the waveform below.

2 comments:
I love sawtooths :D Anyway you could share the code?
yep sure, but you will have to wait for a few days because my computer is broken. :(
Post a Comment