I’ve been working sporadically on this tiny MIDI controller. It targets the smallest PIC microcontroller available with onboard A/D converter – the PIC10F220.
Currently it reads two potentiometers and a button input using three of the GPIO pins, and it bitbangs the remaining output pin to produce MIDI-Out at 31250hz using cycle-counted delays. Since practically everything is already on-chip, this thing could just be epoxied straight to the enclosure. There are only two or three more components – no PCB required!
This microcontroller sports a whopping 256 instructions and 16 bytes of RAM. Even so, the MIDI controller code consumes less than half the available resources after a modest amount of optimization for size. One might see this as my response to using a certain 32k ROM / 2k RAM microcontroller to blink some lights, but I won’t admit to being that petty.
What to do with the remaining space? An easter egg isn’t a bad idea… Hold the button down on boot, and the controller will dump “HTTP://WWW.HACKADAY.COM” as a series of MIDI note-on messages.
Unfortunately I haven’t built the thing yet, but I did simulate it. Here’s the logic analyzer input, showing MIDI messages being sent (delays removed):
You can listen to the result here: EasterEgg.mid
Code follows.
;
;
; Easter Egg: hold button on startup ;-)
btfsc GPIO,GP3 ; 2-3
goto skip_egg
; "note on" running mode
movlw (0x90 | midi_channel)
movwf output
call serial_bitbang
; reset pointer
clrf egg_timer
; "HTTP://WWW.HACKADAY.COM" -> "48 54 54 50 3a 2f 2f 57 57 57 2e 48 41 43 4b 41 44 41 59 2e 43 4f 4d"
egg_loop:
; load ptr into w reg
movfw egg_timer
; go get the next ascii value
call egg_table
; done?
iorlw 0x00
btfsc STATUS,Z
goto skip_egg
; send note (on)
movwf output
call serial_bitbang
; send note volume
movlw 0x7F
movwf output
call serial_bitbang
; delay
movlw 0x7F
movwf output
egg_delay_outer:
movlw 0x7F
movwf temp
egg_delay_inner:
nop
nop
nop
nop
decf temp
btfss STATUS,Z
goto egg_delay_inner
decf output
btfss STATUS,Z
goto egg_delay_outer
; send note (off) - again
movlw egg_timer
call egg_table
movwf output
call serial_bitbang
; send note volume 0x00 == off
clrf output
call serial_bitbang
; next ASCII char
incf egg_timer,f
goto egg_loop
skip_egg:
; Send the first MIDI CC message.
; ...
; ...
; rest of project code...
; ...
; lookup table for hackaday URL
egg_table:
addwf PCL,F ;add offset to pc to
;generate a computed goto
retlw 0x48
retlw 0x54
retlw 0x54
retlw 0x50
retlw 0x3a
retlw 0x2f
retlw 0x2f
retlw 0x57
retlw 0x57
retlw 0x57
retlw 0x2e
retlw 0x48
retlw 0x41
retlw 0x43
retlw 0x4b
retlw 0x41
retlw 0x44
retlw 0x41
retlw 0x59
retlw 0x2e
retlw 0x43
retlw 0x4f
retlw 0x4d
retlw 0x00
END
