Here is my code so far.
define OSC 20 'midi needs a 20 mhz clock DEFINE ADC_BITS 10 ' Set number of bits in result DEFINE ADC_CLOCK 3 ' Set clock source to chip's clock DEFINE ADC_SAMPLEuS 50 ' How long a sample is held in uS ADCON1? = %10000010 'set PORTA analog and right justify result TRISA = %11111111 'set all pins in porta to input pins, pot is
'connected to porta.0
' ## define variables ## txPin var portc.6 'call portc.6 txPin LED var portd.0 'call portd.0 LED Sw1 var portb.7 'call portb.7 Sw1 (switch) x var byte 'dummy variable for initial blinky 'lastSw1 var byte ' Note var byte 'store data from pot NoteLittle? VAR byte
output led output txpin input sw1
for x = 0 to 6
high led
pause 100
low led
pause 200
next
'lastsw1 = sw1 noteLittle = note / 2
main: ADCIN 0, noteLittle ' Read channel 0 to Note
IF sw1 != 0 then
pause 10 'debounce
serout2 txpin, 12, [144, noteLITTLE, 127] 'noteon channel 1, note 80, full volume
PAUSE 1000
serout2 txpin, 12, [144, noteLITTLE, 0] 'noteton channel 1, note 80, 0 velocity (same as note off)
ELSE
high led
pause 500
low led
PAUSE 500
endif
goto main
