Simple analog sequencer and synthesizer

generate neat music with only five basic IC’s

Sample audio is available on Youtube.

Very easy to build and funny to use. Just turn potentiometers and hear how resulting music alters. You can also start to recording your music with computer. It is super easy for example a program called Audacity. Just plug in audio cable and press record.

Building tips

Building is very straightforward. Put components to their places on to the circuit board and solder in place. Potentiometers needs to be assembled with wires. Length is not critical. Watch correct placement and polarity with reference markings from circuit schematics and printed circuit board.

Technical description

Sequencer part of this device is based on classic Baby-10 sequencer. It uses logic 4017 counter and one adjustable low frequency oscillator made from very basic NE555 timer circuit with fixed 50% duty cycle to generate tempo. There is also two other timer used to produce sound frequencies. To save board space one NE556 dual timer is used along with one ordinary NE555.

4017 counter outputs is connected to first of two sound frequency oscillators with 500k adjustable resistor. Outputs is also connected to rotary switch so user can select how many channel is used to produce sound. Common pin of rotary switch is connected to 4017 reset pin. Every output has it’s own adjustable resistor so there is maximum of ten independently controlled frequencies. Them are tied together through diodes. This output is called control voltage. Second sound frequency oscillator is also adjustable with one 500k resistor. It is connected in series with sequencer control voltage so it’s frequency is also based on that.

These two adjustable sound frequencies is mixed together with XOR gate which is made with diode bridge and one BC557 transistor to save board space from yet another logic IC. With this dual tone and mixer combination it is possible to generate classic cowbell sounds. Low frequency oscillator output is called gate and mixed output of two other oscillator is called tone.

Gate pulse is used to generate envelope with adjustable attack and decay times for tone signal. These are controlled by two 500k adjustable resistor. It is buffered with one half of LM358 dual operational amplifier. Other half is unused and it’s inputs are connected to ground. This envelope signal is then used to control tone and these to waveforms are then combined with one BC547 transistor. Finally there is passive low pass filter to filter out unwanted high frequency clicks.

Now our audio signal is ready to be amplified with LM386. At this point there is also signal level output connector for audio. Power amplifier is made with basic circuit with bass boost because we use small speaker. Output level is suitable for 1W, 8ohm speaker. Volume is adjustable with one 10k potentiometer.

Device works with voltages between 5…9 volts. Transformer is not included. Printed circuit board is designed to fit in CP-18-5 enclosure. It is not included. Basically you can use any suitable enclosure.

Setting up LoRa-GPS Tracker

Installing bootloader

Bootloader is pre-installed on board. This information is given if you want to make changes to it. You will need Segger J-Link programmer to follow these instructions and custom adapter to connect with Tag-Connect cable to board.

Clone UF2 repository and make a copy of /boards/feather_mo directory.

cd uf2-samdx1
cd boards
cp -r feather_m0 tracker_m0

Go to that directory and edit board_config.h file as following:


#define VENDOR_NAME "Juha-Pekka Varjonen"
#define PRODUCT_NAME "LoRa-GPS-Tracker"
#define INDEX_URL ""
#define BOARD_ID "SAMD21G18A-Tracker-v1"

#define USB_VID 0x1209
#define USB_PID 0x0005

#define LED_PIN PIN_PA17


You can fill it with your own data if you want. Note that volume label must be 11 character long uppercase string.

Build bootloader with command:

make BOARD=tracker_m0

Go to newly created directory ‘build’ and it’s subdirectory ‘tracker_m0’. If not yet installed, download and install J-Link software from here. Install with this command:

sudo dpkg -i ~/Downloads/jlink_package.deb

To enable/disable bootloader protection you must create two files accordingly to same directory with bootloader.





Start J-Link Commander.


Type ‘connect’ to make connection to microcontroller. It follows with three question. To first question press enter and then ‘S’+enter and then enter again. Default settings are ok.

Please specify device / core. : ATSAMD21G18
Type '?' for selection dialog
Please specify target interface:
  J) JTAG (Default)
  S) SWD
Specify target interface speed [kHz]. : 4000 kHz
Device "ATSAMD21G18" selected.

Clear bootloader protection fuse:

loadfile clear.mot

Reset the target:


Upload the bootloader:

loadbin bootloader.bin,0

Set the bootloader fuse:

loadfile set.mot

Now it should be visible as USB mass storage device and serial port.

Installing CircuitPython

CircuitPython is pre-installed on board. These instructions is given if you want to make changes to it. Clone Adafruit CircuitPython repository:

git clone

An ARM compiler is required for the build. It can be installed as follows:

sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt-get install gcc-arm-embedded

Install necessary submodules before continue:

git submodule update --init --recursive

Next commands must be executed in subdirectory ports/atmel-samd/. Create copy of directory boards/feather_m0_basic and edit file mpconfigboard.h as follows:

#define MICROPY_HW_BOARD_NAME "LoRa-GPS-Tracker"

Then edit file as follows:

USB_VID = 0x1209
USB_PID = 0x0005
USB_PRODUCT = "LoRa-GPS-Tracker"
USB_MANUFACTURER = "Juha-Pekka Varjonen"

Compile MicroPython cross-compiler:

make -C mpy-cross

To build give this command:

make BOARD=tracker_m0

It creates a lot of files and directories in to directory ‘build-tracker_m0’. We only need one with name firmware.uf2. Easiest method to install it is to drag and drop it in to previously created USB device TRACKERBOOT.

After dropping it takes about 15 seconds and device name changes to CIRCUITPY and it’s ready to use.

Setting up development environment

This step is necessary when programming and testing with Mu-editor. Clone Mu-editor repository and edit mu/modes/ file.

git clone
nano mu/mu/modes/

Under ‘valid boards’ add VID and PID to the list. PID 0x0005 is only for testing. Do not use it in production.

valid_boards = [
(0x1209), (0x0005), # LoRa-GPS Tracker development

Run Mu-editor from it’s root directory with command:


Now it should detect LoRa-GPS Tracker automatically. You will need also Adafruit library bundle. Download it from here.

Testing GPS receiver

At first you need to copy adafruit_gps folder from Adafruit library bundle to lib folder on CIRCUITPY device.

Open Mu editor and create new CircuitPython project with filename. File content should be this:

import board
import busio
import adafruit_gps
import time

RX = board.RX
TX = board.TX

uart = busio.UART(TX, RX, baudrate=9600, timeout=30)
gps = adafruit_gps.GPS(uart, debug=False)
# Turn on the basic GGA and RMC info (what you typically want)
# Set update rate to once a second (1hz) which is what you typically want

while True:
    if not gps.has_fix:
        # Try again if we don't have a fix yet.
    # We have a fix! (gps.has_fix is true)
    # Print out details about the fix like location, date, etc.
    print('=' * 40)  # Print a separator line.
    print('Fix timestamp: {:02}:{:02}:{:02}'.format(
    print('Latitude: {0:.6f} degrees'.format(gps.latitude))
    print('Longitude: {0:.6f} degrees'.format(gps.longitude))

That code prints out to serial port current coordinates. You can watch serial port communication by pressing Mu editor button ‘serial’.

Testing LoRa radio

At first you need to copy adafruit_tinylora and adafruit_bus_device folder from Adafruit library bundle to lib folder on CIRCUITPY device.

Open Mu editor and create new CircuitPython project with filename. File content should be this:

import busio
import digitalio
import board
from adafruit_tinylora.adafruit_tinylora import TTN, TinyLoRa
import time
import microcontroller

# Create library object using our bus SPI port for radio
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
# RFM9x Breakout Pinouts
cs = digitalio.DigitalInOut(
irq = digitalio.DigitalInOut(
rst = digitalio.DigitalInOut(

# TTN Device Address, 4 Bytes, MSB
devaddr = bytearray([0x00, 0x00, 0x00, 0x00])
# TTN Network Key, 16 Bytes, MSB
nwkey = bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
# TTN Application Key, 16 Bytess, MSB
app = bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00])
ttn_config = TTN(devaddr, nwkey, app, country='EU')
lora = TinyLoRa(spi, cs, irq, rst, ttn_config)
# Data Packet to send to TTN
data = bytearray(4)
while True:
    # Encode payload as bytes
    data[0] = 0xff
    data[1] = 0x01
    data[2] = 0xff
    data[3] = 0x01
    # Send data packet
    print('Sending packet...')
    lora.send_data(data, len(data), lora.frame_counter)
    print('Packet Sent!')
    lora.frame_counter += 1

Important thing is that TTN device address, network key and application key should be your own unique numbers from TTN Console. More detailed instructions can be found from Adafruit site.

After code is copied to CIRCUITPY drive it runs automatically and starts sending data to internet. You can follow it with TTN Console. If there is no gateway in your area you need one own. Next is described how to setup one.

Setting up LoRaWAN gateway

I have Raspberry Pi with GW-01-RPI LoRa Shield. Start with downloading Rasbian img file from Raspberry Pi’s web site. Extract it with unzip command and transfer to SD card with dd command.

sudo umount /dev/sdx*
sudo dd bs=1M if=your_image_file_name.img of=/dev/sdx

Make sure to replace /dev/sdx with correct device name. You can check it with command sudo fdisk -l

Finally put a empty file named ‘ssh’ to the root directory of SD card. This way you enable ssh connection. Insert card to Raspberry Pi and connect power and LAN. Login with default username and password (user: pi, password: raspberry). With remote computer:

ssh pi@

Change IP address accordingly. It is recommended to change password at this point. Use command passwd.

First enable onboard SPI connection. Go to raspi-config.

sudo raspi-config

Select interfacing options and there is SPI. Enable it by pressing enter and choosing enable.

Create directory and clone and make two necessary repositories on to it.

cd ~
mkdir lora
cd lora
git clone
cd lora_gateway

cd ~/lora
git clone
cd packet_forwarder

Then edit config files:

cd ~/lora/packet_forwarder/lora_pkt_fwd
nano global_conf.json
nano local_conf.json

Local config contains only one line for gateway ID. Change it’s value to same than in global_conf.json. You can make up that ID to be anything you like. It must be 8-bit hexadecimal number. Example settings:

gateway_ID: "0102030405060708"
server_address: ""
serv_port_up: "1700"
serv_port_down: "1700"

One last thing is to make startup file.

cd ~/lora

That file should contain following lines:

echo "25" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio25/direction
echo "1" > /sys/class/gpio/gpio25/value
sleep 3
echo "0" > /sys/class/gpio/gpio25/value
sleep 1
echo "0" > /sys/class/gpio/gpio25/value
cd /home/pi/lora/packet_forwarder/lora_pkt_fwd/
./lora_pkt_fwd &

Set that file to be executable and run it:

sudo chmod +x
sudo ./

If you see line with following text then setup is succesfull.

INFO: [main] concentrator started, packet can now be received

Break that by pressing Ctrl-C. Next thing is to modify rc.local file.

sudo nano /etc/rc.local

Just before ending “exit 0” line, add following:

/home/pi/lora/ || /bin/true &

And on the beginning of the file change “#!/bin/sh -e” to “#!/bin/sh”. Save and close file. Then set executable bit and enable it:

sudo chmod +x /etc/rc.local
sudo systemctl daemon-reload
sudo systemctl enable rc-local.service

Now it should start every time when Raspberry starts. Restart to confirm that by typing ‘sudo reboot’ and pressing enter. When restarted look with top command if lora_pkt_fwd is running.

Setting up TTN

Start by logging in to TTN console and choose Gateway -> register gateway. Select “I’m using the legacy packet forwarder”. Important thing is that gateway EUI must be same than previously selected Gateway_ID. Also router needs to be same than in gateway settings. Other settings are self-explanatory.

LoRaWAN GPS Tracker

Image is coming as soon as first devices arrives from manufacturer…

Only 20 different component. What could you except for that?

For use in EU and India. Suitable band is software controlled. Fully hackable open source software design with CircuitPython language. Ready to use. Program includes advanced power saving techniques. Extreme small physical size yet powerful tracking device. Free subscription to mapping service. And there’s more!

Includes panic button which can send GPS coordinates to pre-selected recipients through SMS and email. Includes battery level monitoring service through LoRaWAN uplink. You can select where and how to send that data. It is automatically saved to database like all other messages from device. Only you have access to that data from backend which is password protected web site.

Tri-color LED indicates when battery is fully charged and when there is GPS fix. Red color is programmable and by default it is showing operational status of the device. Battery charging and programming through micro USB port.

Device is water resistant to IP65. It can be used outdoor. GPS position accuracy < 3 meters. Stand alone operation time from days to week depending on how often GPS tracking is made.

Advantages to use CircuitPython includes but not limited to:
Perfect choice for data logging applications. Internal storage is seen as USB storage device. Easily update your code. Since your code lives on the disk drive, you can edit it whenever you like. And Python is fastest-growing programming language. It’s taught in schools and universities.

Internal battery voltage 3.7V, battery type LiPo and capacity 105mA. Integrated charging circuit from USB port whenever USB is connected to computer. Over and under voltage protected. Automatic switch between USB and battery depending on USB connection.

Physical dimensions of durable black ABS plastic enclosure are 36mm x 66mm. Height only 17mm. It includes a key fob ring so you can connect it to keys and never lose those keys again!

Usage examples includes ofcourse person tracking obviously but also a industrial logistics tracking applications. And many more. It can freely adopted to different usages by simply changing Python code inside it. And it’s easy than plugging it into computer. It shows up a external drive where you can put your code and it is run instantly!

Welcome to!

I’m 35 years old programmer from Tampere, Finland.

This is my personal web site. 

I work on electronic design, construction and programming. It is also my hobby. on this site I will present some of the hobby projects I have made. I also have a radio amateur qualification. Self-learning and experimentation through hobby has since taught much more.

Embedded systems have always attracted me. nowadays they are everywhere. It refers to a device with a microprocessor and program code in it. Almost all my hobby projects are like that.

Battery level indicator

This device monitors battery voltage and shows it on 5 LED’s. Further development will include a use of AVR power saving functions. At this moment circuit uses 31mA. LED position vs. voltage:

  1. <= 12.05
  2. 12.06 – 12.25
  3. 12.26 – 12.45
  4. 12.46 – 12.65
  5. >= 12.66

Full lead acid battery has 12.7V and when it’s empty voltage is under 12.0V. Below is circuit diagram. All works just as planned. Simple math.

Here is Arduino code before power saving functions:

/* battLow2.ino

void setup() {
  // initialize LED outputs

  // LED's to off state

void loop() {

  int val = analogRead(A5); // 0 to 1023

  // voltage divider input---56---22---gnd
  // (1023/17.727) * voltage
  if(val <= 695) {
  } else if(val > 695 && val < 706) {
  } else if(val >= 706 && val < 718) {
  } else if(val >= 718 && val < 730) {
  } else if(val > 730) { // 12.65

After adding power saving things to code current consumption is only 18mA. It contains LED driving current and power dissipation of the linear regulator. AVR restarts every two seconds to make one ADC measurement.

/* battLow2.ino
 * Displays 12V lead acid battery voltage level on LED bar
 * Author:
 * Copyright (C) 2019 Juha-Pekka Varjonen

#include <avr/sleep.h>
#include <avr/wdt.h>
#include <avr/power.h>

void setup() {

  // power up every 2 seconds
  // set sleep mode (not activated yet)
  // disable things
  // initialize LED outputs

  int val = analogRead(A5); // 0 to 1023

  // disable ADC

  // voltage divider input---56---22---gnd
  // (1023/17.727) * voltage
  if(val <= 695) {
  } else if(val > 695 && val < 706) {
  } else if(val >= 706 && val < 718) {
  } else if(val >= 718 && val < 730) {
  } else if(val >= 730) { // 12.65

  // go to sleep (watchdog will restart)

void loop() {
  // nothing here

Little improvement to circuit. Now it’s current consumption is only 11mA.