Hi, new user to the forum. Warning this will be a lengthy posts. Sorry in advance.
Well a little background might help. I'm a classic car restorer. One of my customers has a road legal Dalek based off a Mini. He brought it in for a resto-mod and wanted FX installing. Like an idiot I said "No problem" and hence I'm here. Some of what I've managed to do myself is quite nice, 40 random flashing led's, in 8 groups of 5, on the dashboard using 1 18M2. I've got the SPE035 working playing random music. I've written the code to articulate the Dalek gun, Eye stalk and Eye Iris. I've even managed to, although not tested fully, get the picaxe controlling the servo's to talk to the picaxe controlling the Gun light and Eye light. What I would like is the gun light to flash and as it does so send a signal to the SPE035 to play the gun noise. I understand this should be possible if I put the gun noise file as an advert but this bit is way over my head. I'll try list below the systems I have and how they are broken down to make my life easier (or so I think). I would appreciate any feedback/help you could give me.
all code at bottom.
Servo Picaxe 18M2 controlling Dalek gun (2 servo's) and Dalek eye (2 servo's) independently.
Light control Picaxe 18M2 controlling Dalek eye light and Dalek gun light independently.
Music Picaxe SPE035 playing Dr Who music and other tracks randomly.
Head Picaxe (yet to work on, to control a motor to swing the head about)
Smoke Picaxe 18M2 to control a smoke machine and produce smoke effect under the Dalek at random times and lengths.
Dash light Picaxe 18M2 to flash 40 lights as described above.
Servo Picaxe takes a digital input (a switch) on 2 inputs to turn on either the eye movement or the gun (or both). This then outputs to the Light control Picaxe to turn on the Eye light and the Gun light (Gun effect to light up as it would fire). Brief explanation why those are separate, Servo's are 5v and the lights are 12v. Thinking as I'm typing it might be better voltage wise to get the servo control picaxe to talk to SPE035 AND the Light control picaxe to play the noise and flash the lights as obviously for ease the Light control is running with the 12V modification. I've yet to write the Light Control Picaxe code as it should be straightforward....wait for input and then turn on a light.
God I hope that lot made sense to someone.
Code is below for you to laugh at and tell me to rewrite the lot "you bloody idiot"
SPE035 music picaxe
Thanks for your patience.
*edited to include my further terrible code*
Smoke machine
Well a little background might help. I'm a classic car restorer. One of my customers has a road legal Dalek based off a Mini. He brought it in for a resto-mod and wanted FX installing. Like an idiot I said "No problem" and hence I'm here. Some of what I've managed to do myself is quite nice, 40 random flashing led's, in 8 groups of 5, on the dashboard using 1 18M2. I've got the SPE035 working playing random music. I've written the code to articulate the Dalek gun, Eye stalk and Eye Iris. I've even managed to, although not tested fully, get the picaxe controlling the servo's to talk to the picaxe controlling the Gun light and Eye light. What I would like is the gun light to flash and as it does so send a signal to the SPE035 to play the gun noise. I understand this should be possible if I put the gun noise file as an advert but this bit is way over my head. I'll try list below the systems I have and how they are broken down to make my life easier (or so I think). I would appreciate any feedback/help you could give me.
all code at bottom.
Servo Picaxe 18M2 controlling Dalek gun (2 servo's) and Dalek eye (2 servo's) independently.
Light control Picaxe 18M2 controlling Dalek eye light and Dalek gun light independently.
Music Picaxe SPE035 playing Dr Who music and other tracks randomly.
Head Picaxe (yet to work on, to control a motor to swing the head about)
Smoke Picaxe 18M2 to control a smoke machine and produce smoke effect under the Dalek at random times and lengths.
Dash light Picaxe 18M2 to flash 40 lights as described above.
Servo Picaxe takes a digital input (a switch) on 2 inputs to turn on either the eye movement or the gun (or both). This then outputs to the Light control Picaxe to turn on the Eye light and the Gun light (Gun effect to light up as it would fire). Brief explanation why those are separate, Servo's are 5v and the lights are 12v. Thinking as I'm typing it might be better voltage wise to get the servo control picaxe to talk to SPE035 AND the Light control picaxe to play the noise and flash the lights as obviously for ease the Light control is running with the 12V modification. I've yet to write the Light Control Picaxe code as it should be straightforward....wait for input and then turn on a light.
God I hope that lot made sense to someone.
Code is below for you to laugh at and tell me to rewrite the lot "you bloody idiot"
Code:
' For Picaxe M18M2
' Servo picaxe
' 1 start operation to control the other
' 4 start operations so they run simultaneously
' Initial servo values are generic until limits are known and can be thus set.
Symbol eyeinput = pinC.0
Symbol guninput = pinC.1
Symbol iris = w1
Symbol eyeV = w3
Symbol gunH = w5
Symbol gunV = w7
Symbol wait1 = w9
Symbol wait2 = w11
Symbol wait3 = w13
start0:
if eyeinput = 1 then start1 ' Take input from Eye control switch and run Start 1
if eyeinput = 1 then start2 ' Take input from Eye Control switch and run start 2
if guninput = 1 then start3 ' Take input from Gun control switch and run Start 3
if guninput = 1 then start4 ' Take input from Gun control switch and run Start 4
' Send signal to light control Picaxe to turn on Eye light
if eyeinput = 1 then
high B.7
else if eyeinput = 0 then
low B.7
end if
goto start0
start1:
' Iris Servo, activate the iris servo to open and close the iris at random
Do
random w0
b18 = w0/142//3000+1
loop until b18<>b19
b19=b18
' generate a reasonable quality random number
random w8
iris = b19
iris = b19//195+10 ' random servo setting
wait1 = w8
wait1 = w8//3000+500 ' random delay between movements
servo 1,iris ' move iris servo
pause wait1 ' delay before next move
goto start0
start2:
' Eye Vertical, activate
Do
random w2
b20 = w2/102//3000+1
loop until b20<>b21
b21=b20
' generate a reasonable random number
random w10
eyeV = b21
eyeV = b21//195+10 ' random servo setting
wait2 = w10
wait2 = w10//3000+500 ' random delay between movements
servo 2,eyeV ' move eye stalk up/down
pause wait2 ' delay between movements
goto start0
start3:
' Gun Horizontal, move the gun horizontally
random w4
random w12
gunH = w4
gunH = w4//195+10 ' random servo setting
wait3 = w12
wait3 = w12//3000+500 'random delay between movements
servo 3,gunH ' move servo
pause wait3 ' delay between movements
goto start0
start4:
' Gun Vertical, move the gun vertically
random w6
gunV = w6
gunV = w6//195+10 ' random servo setting
servo 4,gunV ' move servo
pause wait1 ' delay between movements
goto start0
Code:
'BASIC converted from file:
'C:\ProgramData\Revolution Education\PICAXE Editor\Samples\Blockly\AXE171 - PICAXE 14 Audio Kit\14M2\AXE171 - Play Sequential.xml
'Converted 2020-11-15 at 20:55:27
' Code modified from the sample file as I have no clue about what is needed by
' way of programming and what can be discarded.
symbol varA = w0
main1:
high B.4
pause 1
setfreq m8
serout B.4, T9600_8, ($7E, $FF, $06, $09, $00, $00, $02, $EF) ;SPE035 initialise
setfreq mdefault
pause 100
pause 4000
setfreq m8
serout B.4, T9600_8, ($7E, $FF, $06, $06, $00, $00, 20, $EF) ;SPE035 volume
setfreq mdefault
pause 100
pause 1000
do
random w1
let VarA = w1
VarA = w0//13+1 ' select a random track and play.
setfreq m8
serout B.4, T9600_8, ($7E, $FF, $06, $12, $00, $00, varA, $EF) ;SPE035 play
setfreq mdefault
pause 100
pause 500
do
pause 10
loop until pinC.2 = 1
loop
stop
*edited to include my further terrible code*
Smoke machine
Code:
' For Picaxe 18M2
' Smoke machine
' random fire smoke effect switching a 12v DC to 240v AC relay on B.0
Symbol dosmoke = w6
Symbol delay = w11
' following code waits for an input on C.0 which corresponds to
' the smoke machine getting up to temperature, switching done via
' a relay to protect picaxe from 240v AC
main:
if pinC.0 = 1 then
do
pause 10
loop until pinC.0 = 0
else
call Smoke
endif
' Following code should randomly fire smoke for a random length of time
' between a random length delay
' I am trying to set the delay to be up to a minute ( smaller length of
' time during testing will be set )
Smoke:
do
' 3 do loops to create a large enough quality random number
do
random w0
b5 = w0/198//4000+1
loop until b5<>b6
b6 = b5
do
random w1
b7 = w1/350//4000+1
loop until b7<>b8
b8 = b7
do
random w2
b9 = w2/42//4000+1
loop until b9<>b10
b10 = b9
w5 = b6+b8+b10 ' add the 3 random numbers
w6 = w5*10 ' multiply the result by 10
' This is a lengthy procedure but during testing using
' a simpler random number generation did not give a
' random result!?!
random w10
w11 = w10//20000+5000 ' set the length of delay between firings
pause delay
high B.0 ' fire smoke
pause dosmoke ' for this length of time
low B.0 ' turn off smoke
' the following checks that the smoke machine is still at temperature
' and either returns to main to wait until it is, or loops through
' producing smoke.
if pinC.0 = 1 then
Goto main
else
end if
loop
return
Last edited: