Code:
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
'* MIDI Remote for Reaper 20 MHz resonator (HS) *
'* PIC16F628 *
'* PORTB.0 = Rewind *
'* PORTB.1 = FastFwd. *
'* PORTB.2 = Stop *
'* PORTB.3 = Play *
'* PORTB.4 = Record *
'* PORTB.7 = Output *
'* Version 1.0 03 March 2024 *
'* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
CMCON = 7 ' Digital mode
DEFINE OSC 20 ' 20 MHZ OSC.
'DEFINE BUTTON_PAUSE 50 ' Is this needed ?
TRISB= %00111111 ' PORTB 6..7=Output 0..5=Input
BTN1 var Byte ' Button variables for internal use
BTN2 var byte
BTN3 var byte
BTN4 var byte
BTN5 var byte
BTN1 = 0 ' Initialize button variables
BTN2 = 0
BTN3 = 0
BTN4 = 0
BTN5 = 0
Progstart:
BUTTON PORTB.0, 1, 255, 0 , BTN1, 0 , But2
Serout2 PORTB.7, 16384+12, [144, 44, 127] ' Rewind
But2:
BUTTON PORTB.1, 1, 255, 0 , BTN2, 0 , But3
Serout2 PORTB.7, 16384+12, [144, 46, 127] ' Fast Fwd.
But3:
BUTTON PORTB.2, 1, 255, 0 , BTN3, 0 , But4
Serout2 PORTB.7, 16384+12, [144, 48, 127] ' Stop
But4:
BUTTON PORTB.3, 1, 255, 0 , BTN4, 0 , But5
Serout2 PORTB.7, 16384+12, [144, 50, 127] ' Play
But5:
BUTTON PORTB.4, 1, 255, 0 , BTN5, 0 , ProgStart
Serout2 PORTB.7, 16384+12, [144, 52, 127] ' Record
Goto Progstart
The moral: never try to reinvent the wheel!
Bookmarks