here is the code so far. I added a conditional statement to the LCD output to fix if the value is less than 4 digits. Fixed the analog pin assignments. Added the sliders. Made a splash screen. Nothing major.
[code]; declare variables here
cha1 var word
cha2 var word
cha3 var word
cha4 var word
cha5 var word
cha6 var word
cha7 var word
a_key var bit
b_key var bit
c_key var bit
; create variables for averaging code
index var byte
buffer1 var word(8)
buffer2 var word(8)
buffer3 var word(8)
buffer4 var word(8)
buffer5 var word(8)
buffer6 var word(8)
sum1 var word
sum2 var word
sum3 var word
sum4 var word
sum5 var word
sum6 var word
; initialize each buffer element, each sum, and then index to 0
for index = 0 to 7
buffer1(index) = 542
buffer2(index) = 542
buffer3(index) = 542
buffer4(index) = 542
buffer5(index) = 542
buffer6(index) = 542
next
sum1 = 4336
sum2 = 4336
sum3 = 4336
sum4 = 4336
sum5 = 4336
sum6 = 4336
index = 0
; initialize unused channels outside the main loop
cha7=1500
; chirpy squeak kinda thing
sound 9, [100\880, 100\988, 100\1046, 100\1175] ;musical notes, A,B,C,D.
; wake up the Matrix Orbital display module
;serout 8,i19200,[254, 66, 0] ;Backlight on, no timeout.
;serout 8,i19200,[254, 64, “The D-I-Y 2.4ghzRobot Radio Set!”] ;startup screen. Do only once…
pause 5000
serout 8,i19200, [254, 88] ;clear screen
; initialize the ppm output signal
low 15
; — top of main loop —
start:
; averaging expects that the a/d values are < 4096
; for each channel
; read the a/d
; subtract the previous value from 8 samples ago from the sum
; store the new value in the circular buffer
; add the new value to the sum
; divide the sum by 8 to get the average value
; convert joystick values 392 - 692 to servo values 1000uS - 2000uS
adin 2, cha1 ; right vertical
sum1 = sum1 - buffer1(index)
buffer1(index) = cha1
sum1 = sum1 + cha1
cha1 = sum1 / 8
cha1 = (((cha1*42)-6500)/10)
adin 3, cha2 ; right horizontal
sum2 = sum2 - buffer2(index)
buffer2(index) = cha2
sum2 = sum2 + cha2
cha2 = sum2 / 8
cha2 = (((cha2*42)-6500)/10)
adin 0, cha3 ; left vertical
sum3 = sum3 - buffer3(index)
buffer3(index) = cha3
sum3 = sum3 + cha3
cha3 = sum3 / 8
cha3 = (((cha3*42)-6500)/10)
adin 1, cha4 ; left horizontal
sum4 = sum4 - buffer4(index)
buffer4(index) = cha4
sum4 = sum4 + cha4
cha4 = sum4 / 8
cha4 = (((cha4*42)-6500)/10)
adin 18, cha5 ; Left slider
sum5 = sum5 - buffer5(index)
buffer5(index) = cha5
sum5 = sum5 + cha5
cha5 = sum5 / 8
cha5 = cha5 + 988
adin 19, cha6 ; Right slider
sum6 = sum6 - buffer6(index)
buffer6(index) = cha6
sum6 = sum6 + cha6
cha6 = sum6 / 8
cha6 = cha6 + 988
; finally increment the index and limit its range to 0 to 7.
index = (index + 1) & 7
; update the display module
branch index, [update1,update2,update3,update4,update5,update6,update7,update8]
update8:
serout 8, i19200, [254, 71, 11, 2, “A”]
goto makepulses
update7:
serout 8, i19200, [254, 71, 11, 1, “0”]
goto makepulses
update6:
if cha6<1000 then update62
serout 8, i19200, [254, 71, 6, 2, dec cha6]
goto makepulses
update62:
serout 8, i19200, [254, 71, 6, 2, " ", dec cha6]
goto makepulses
update5:
if cha5<1000 then update52
serout 8, i19200, [254, 71, 6, 1, dec cha5]
goto makepulses
update52:
serout 8, i19200, [254, 71, 6, 1, " ", dec cha5]
goto makepulses
update4:
if cha4<1000 then update42
serout 8, i19200, [254, 71, 1, 2, dec cha4]
goto makepulses
update42:
serout 8, i19200, [254, 71, 1, 2, " ", dec cha4]
goto makepulses
update3:
if cha3<1000 then update32
serout 8, i19200, [254, 71, 1, 1, dec cha3]
goto makepulses
update32:
serout 8, i19200, [254, 71, 1, 1, " ", dec cha2]
goto makepulses
update2:
if cha2<1000 then update22
serout 8, i19200, [254, 71, 13, 2, dec cha2]
goto makepulses
update22:
serout 8, i19200, [254, 71, 13, 2, " ", dec cha2]
goto makepulses
update1:
if cha1<1000 then update12
serout 8, i19200, [254, 71, 13, 1, dec cha1]
goto makepulses
update12:
serout 8, i19200, [254, 71, 13, 1, " ", dec cha1]
goto makepulses
; build and send the ppm output
makepulses:
pulsout 15,800
pauseus ((cha12)-800)
pulsout 15,800
pauseus ((cha22)-800)
pulsout 15,800
pauseus ((cha32)-800)
pulsout 15,800
pauseus ((cha42)-800)
pulsout 15,800
pauseus ((cha52)-800)
pulsout 15,800
pauseus ((cha62)-800)
pulsout 15,800
pauseus ((cha7*2)-800)
pulsout 15,800
; do it again ad infinitum
goto start [/code]