this board is using an old raspberry pi 1 to control the speed of computer fans. the electronics are pretty simple (see attached schematics below): it takes 7-36V input power, has twelve mosfets for pwm control and finally a dc/dc converter to power the rpi.
it was built for controlling pc cooling fans but can also drive other types of dc motors, lightbulbs or solenoids.
the off button is there to safely power down the raspberry pi.

the trick with this though is that the system can be livecoded over wifi using supercollider, maxmsp or any other osc capable program. so when you start the board the rpi sets up a wireless access point and starts a python script that accepts incoming opensoundcontrol messages. at startup the rpi1 will also start supercollider and load a file (dragspelFans.scd) that is meant to contain whatever code you'd like to run as default. this file you later overwrite with your own sc code that you've developed/livecoded using your laptop.


below are step-by-step instructions on how i set this up plus the relevant python and supercollider code. it should work on all rpi models but here the rpi1 or rpi0 is assumed.

* download and install raspbian-stretch-lite onto a 2gb sd card
* to enable ssh create an empty file on the sd card. call it ssh. (this terminal command touch /Volumes/boot/ssh will do it on osx or just create an empty textfile and save it without any file extension)
* connect your rpi to your home router via ethernet and type the following in terminal on your laptop:
* ssh-keygen -R raspberrypi.local
* ssh pi@raspberrypi.local #default password is raspberry
* sudo raspi-config #change password to _____, set memory split to 16 under advanced, change hostname to fans under network, update, finish and reboot (sudo reboot)
* ssh pi@fans.local #log in again from your laptop
* sudo apt-get update
* sudo apt-get upgrade
* sudo apt-get dist-upgrade

this section will install osc and gpio libraries for python and also set up the python script to automatically start at system boot.
* sudo apt-get install python-liblo pigpio python-pigpio
* sudo crontab -e #and add the following line at the end (use ctrl+o and ctrl+x to save and exit):

@reboot /usr/bin/pigpiod -s 5 && /usr/bin/python /home/pi/dragspelFans.py

* nano ~/dragspelFans.py #and copy&paste in the following:

#pwm control for 12 fans/motors/leds

#NOTE: make sure to run this in terminal first...
# sudo pigpiod -s 5

import sys
from os import system
from time import sleep
import pigpio
from liblo import *

inport= 9999  #for osc commands to this python script
pinoff= 2  #bcm numbering
pins= [3, 4, 14, 15, 17, 18, 27, 22, 23, 24, 10, 9]  #bcm numbering - more can be added here
target= ('', 57120)  #for osc to sclang
hz= 800  #pwm frequency in hz - note may need to adapt -s option in sudo pigpio -s 5 above
range= 100  #duty cycle range 0 to 100

pi= pigpio.pi()
pi.set_mode(pinoff, pigpio.INPUT)  #no internal pullup needed
for pin in pins:
  pi.set_mode(pin, pigpio.OUTPUT)
  pi.set_PWM_frequency(pin, hz)
  pi.set_PWM_range(pin, range)
  pi.set_PWM_dutycycle(pin, 0)

class MyServer(ServerThread):
        def __init__(self):
                ServerThread.__init__(self, inport)
        @make_method('/pwms', 'i'*len(pins))
        def pwms_callback(self, path, args):
                #print args  #debug
                i= 0
                for pin in pins:
                        pi.set_PWM_dutycycle(pin, min(max(0, args[i]), range))
                        i= i+1
        @make_method('/shutdown', '')
        def shutdown_callback(self, path, args):
                stop('sudo halt -p')  #turn off rpi
        @make_method('/reboot', '')
        def reboot_callback(self, path, args):
                stop('sudo reboot')  #reboot rpi
        @make_method('/start', '')
        def start_callback(self, path, args):
                send(target, '/start', 1)  #start default program in supercollider
        @make_method('/stop', '')
        def stop_callback(self, path, args):
                send(target, '/stop', 0)  #stop default program in supercollider
                for pin in pins:  #and also set all pwm to 0
                        pi.set_PWM_dutycycle(pin, 0)
        @make_method(None, None)
        def fallback(self, path, args):
                print 'received unknown message "%s"' % path

def stop(cmd):
        system('killall pigpiod sclang')

        server= MyServer()
except ServerError, err:
        print str(err)

def main():
        while True:
                if pi.read(pinoff)==0:
                        print 'shutting down...'
                        stop('sudo halt -p')

if __name__ == '__main__':
        except KeyboardInterrupt:

again use ctrl+o and ctrl+x to save and exit. now sudo reboot and then try to send osc commands to the rpi. here's how to send some test osc messages from your laptop to the rpi using supercollider...

n= NetAddr("fans.local", 9999);
n.sendMsg(\pwms, *[50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])  //the number of integers should match the number of pins and range in your python code (here 12 pins, 0-100)
n.sendMsg(\pwms, *[25, 50, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0])  //first pin 25%, second %50 third 75%, rest 0
n.sendMsg(\pwms, *[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])  //all off

you can also try to connect pin bcm2 to ground. that should now act like an off button and turn off the rpi in a safe way.

this section is optional. only install supercollider if you want to run your rpi as a standalone installation or something similar. so if you plan to always remote control the system you can skip over this step.
note: this is for rpi0&rpi1, for rpi2&rpi3 change all references to supercolliderStandaloneRPI1 below to supercolliderStandaloneRPI2
see https://github.com/redFrik/supercolliderStandaloneRPI1#stretch-lite for more details (this page also show how to install jackd if you need audio from your rpi).
* sudo apt-get install libqt5webkit5 libqt5sensors5 libqt5positioning5 libfftw3-bin libcwiid1 git libasound2-dev libsamplerate0-dev libsndfile1-dev libreadline-dev xvfb libjack-jackd2-0
* cd ~
* git clone https://github.com/redFrik/supercolliderStandaloneRPI1 --depth 1
* mkdir -p ~/.config/SuperCollider
* cp supercolliderStandaloneRPI1/sc_ide_conf_temp.yaml ~/.config/SuperCollider/sc_ide_conf.yaml
* cd supercolliderStandaloneRPI1
* nano autostart.sh #and change the script to look like this:

./sclang -a -l sclang.yaml ../dragspelFans.scd

* nano share/user/startup.scd #and add the following two lines:

OSCFunc({"/home/pi/dragspelFans.scd".load}, \start).permanent= true;
OSCFunc({CmdPeriod.run}, \stop).permanent= true;

* mkdir share/user/Extensions
* nano share/user/Extensions/DragspelFans.sc #and copy&paste in the following:

//f.olofsson2016-2018 - for controlling 12ch computer fan switch board
DragspelFans {
        var <rpi, num, vals, lastv, <>debug;
        *new {|debug= false, rpi, num= 12|
                ^super.new.initDragspelFans(debug, rpi, num);
        initDragspelFans {|d, r, n|
                num= n;
                if(r.notNil, {
                        rpi= r;
                }, {
                                rpi= NetAddr("fans.local", 9999);
                        } {|err|
                                "could not connect to rpi.\n make sure you are connected to the wifi network 'dragspel'.".warn;
                                rpi= NetAddr("", 9999);  //temp just for testing
                debug= d;
                vals= 0!num;

        setAll {|val= 100|  //val should be 0 to 100
                vals= val!num;
        clearAll {
                vals= 0!num;
        val {|index, val|  //index should be 0-11, val 0-100
                vals= vals.put(index, val);
        arr {|arr|  //arr should be 12 numbers in an array
                vals= arr;

        shutdown {
        reboot {
        start {
        stop {

        prSend {|v|
                if(debug, {
                v= vals.clip(0, 100).round.asInteger;
                if(v!=lastv, {  //filter out repeats
                        lastv= v;
                        rpi.sendMsg(\pwms, *v);  //send to dragspelFans.py

* nano ~/dragspelFans.scd #and copy&paste in the following:

//demo autostart script - put your own standalone code in here
d= DragspelFans.new;
Event.addEventType(\fans, {d.val(~index, ~val)});
Pbind(\type, \fans, \dur, 0.5, \index, Pseq([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], inf), \val, Pwhite(0, 100, inf)).play;

* crontab -e #and add the following to the end (note no sudo here this time)

@reboot cd /home/pi/supercolliderStandaloneRPI1 && xvfb-run ./autostart.sh

now sudo reboot and supercollider should automatically start the code in dragspelFans.scd. it'll take a while so give it a minute or two.

to test it more run the following supercollider code on your laptop...

n= NetAddr("fans.local", 9999);
n.sendMsg(\stop);  //first stop the dragspelFans.scd script
n.sendMsg(\pwms, *[25, 50, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0]);  //set pwm manually

//install the DragspelFans.sc class on your laptop sc and also try the following example code

a= DragspelFans(true);  //might take a moment or two
CmdPeriod.doOnce({a.clearAll});  //optional

//version0 - all on or off
a.setAll(50)  //set all to some value 0-100

//version1 - using an array
a.arr([0, 0, 100, 0, 0, 100, 0, 0, 100, 0, 0, 100])  //turn on some
a.arr([0, 100, 0, 0, 100, 0, 0, 100, 0, 0, 100, 0])  //turn some other fans
a.arr([30, 0, 0, 40, 100, 0, 40, 0, 0, 80, 0, 0])  //a few slower

//version2 - set index to value
a.val(9, 100);
a.val(9, 0);
a.val(11, 100);
a.val(11, 0);
a.val(11, 60);
a.val(11, 0);

//fade in each fan in order
r= Routine.run({
                        a.val(j, i);
                        a.val(j, 99-i);

//using patterns
a= DragspelFans.new;
Event.addEventType(\fans, {a.val(~index, ~val)});
Pdef(\test, Pbind(\type, \fans, \dur, 0.125, \index, Pseq([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].scramble, inf), \val, Pwhite(0, 100, inf))).play;

a.start;  //start the dragspelFans.scd script on the rpi again

or test it using the attached maxmsp patch.


//--wifi softap
this section is optional. it will set up a wifi access point served from the rpi. basically taken from https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md
* sudo apt-get install dnsmasq hostapd
* sudo systemctl stop dnsmasq
* sudo systemctl stop hostapd
* sudo nano /etc/dhcpcd.conf #and add the following to the end:

interface wlan0
    static ip_address=

* sudo service dhcpcd restart
* sudo nano /etc/dnsmasq.conf #and add the following two lines to the bottom:


* sudo nano /etc/hostapd/hostapd.conf #and add the following (remember to set passphrase 8-64 characters):


* sudo nano /etc/default/hostapd #and change one line to the following:


* sudo systemctl start hostapd
* sudo systemctl start dnsmasq

now sudo reboot on the rpi, log on to dragspel wifi network from your laptop and try to send some osc commands.

update 180225: major rewrite to use pigpio instead of RPi.GPIO and also raspbian stretch instead of jessie. pwm works much better.