So I thought I would ask the Picaxe gurus before I hook everything up and perhaps fry something.
I want one 18M2 to tell another 18M2 when to run code. I think this can be accomplished by connecting an output pin from one 18M2 to an input pin on the other
18M2. The pin on the first picaxe will go high, the second picaxe will look for the it's input to =1 and then run code.
I have read through a number of threads trying to find an answer to this. I realize that by using the serin/serout commands that this can be accomplished, however I am not familiar enough with serial protocols to write the code for that (note that I did use serout commands in first code, but only because those commands where clearly laid out in the MDFly datasheet and in the thread on Tenda modules on this forum). Here is the (abbreviated) code for the controlling Picaxe, Symbol Brunny_Fly =C.2 is the command.
Here is the code for the controlled Picaxe.
thanks in advance for your input.
I want one 18M2 to tell another 18M2 when to run code. I think this can be accomplished by connecting an output pin from one 18M2 to an input pin on the other
18M2. The pin on the first picaxe will go high, the second picaxe will look for the it's input to =1 and then run code.
I have read through a number of threads trying to find an answer to this. I realize that by using the serin/serout commands that this can be accomplished, however I am not familiar enough with serial protocols to write the code for that (note that I did use serout commands in first code, but only because those commands where clearly laid out in the MDFly datasheet and in the thread on Tenda modules on this forum). Here is the (abbreviated) code for the controlling Picaxe, Symbol Brunny_Fly =C.2 is the command.
Code:
'#18M2 Witch scene
symbol Aggie = B.0 'MDFly 1 RX
symbol Gertie = B.2 'MDFly 2 RX
symbol Aggie_BZ = pinB.1 'MDFly 1 Busy
symbol Gertie_BZ =pinB.3 'MDFly 2 busy
symbol Cauldron = B.4 'MDFLY 3 RX
symbol Cauldron_BZ = pinB.5 'MDFly 3 RX
symbol Thunder = B.6'MDFly 4 RX
symbol Thunder_BZ = pinB.7 'MDFly 4 Busy
symbol Brunny_Fly = C.2
symbol Baud =T4800 'tenda baud Rate
symbol Trigger =C.1 'trigger, probably PIR
symbol debounce = b5
symbol Retriggertime = w5
Start0:
Retriggertime = 120
Init:
high Aggie 'prepare MDFly 1
pause 400
high Gertie 'prepare MDFly 2
pause 400
pause 400
serout Aggie,Baud,($EF) 'stop MDFly 1
serout Gertie, Baud, ($EF)'stop MDFly 2
serout Thunder, Baud, ($EF) 'stop MDFly 4
pause 6000 'wait 10 seconds
serout Aggie, Baud, ($E8) 'set MDFly 1 volume
serout Gertie, Baud, ($E8) 'set MDFly 2 volume
serout Thunder, Baud, ($E8) 'set MDFly 4 volume
pause 60000 'wait 1 minute
Waiting:
debounce = 0
Do
let w0 = time
random w0
If debounce > 50 then
goto Happy_Halloween
pause 3000
Endif
readadc Trigger, debounce
loop while debounce < 50
Happy_Halloween:
serout Aggie, Baud, ($F2,09)
pause 2000
do while Aggie_BZ = 0
loop
serout Aggie,Baud,($F2,01)
serout Gertie,Baud, ($F2,01)
pause 2000
do while Aggie_BZ = 0
loop
serout Gertie, Baud, ($F2,02)
pause 2000
do while Gertie_BZ = 0
loop
serout Aggie, Baud, ($F2,03)
pause 2000
do while Aggie_BZ = 0
loop
serout Gertie, Baud, ($F2,04)
pause 2000
do while Gertie_BZ = 0
loop
serout Aggie, Baud, ($F2,05)
pause 2000
do while Aggie_BZ = 0
loop
serout Thunder, Baud, ($01)
pause 2000
do while Thunder_BZ = 0
loop
serout Aggie, Baud, ($F2,06)
pause 2000
do while Aggie_BZ = 0
loop
serout Gertie, Baud, ($F2,06)
pause 2000
do while Gertie_BZ = 0
loop
serout Aggie, Baud, ($F2,07)
pause 2000
do while Aggie_BZ = 0
loop
high Brunny_Fly 'send high to second picaxe input
serout Thunder, Baud, ($01)
serout Aggie, Baud, ($F2,10)
serout Gertie, Baud, ($F2, 08)
pause 2000
do while Aggie_BZ = 0
loop
goto Spellcast
Code:
'#18M2 Flying witch
symbol Up_Away = B.3
symbol Side2Side = B.4
symbol FX = B.5
symbol Trigger = pinC.1
Start0:
Waiting:
do
let w7 = time
random w7
if Trigger = 1 then 'if pin on first picaxe goes high, run program
goto Flying
endif
loop
Flying:
High Up_Away
random w7
w8=w7//1000 + 5000 'random ON time between 1 and 5 seconds
pause w8
Low Up_Away
random w7
w8=w7//1000 + 3000 'random OFF time between 1 and 5 seconds
pause w8
High Up_Away
random w7
w8=w7//1000 + 5000 'random ON time between 1 and 5 seconds
pause w8
Low Up_Away
random w7
w8=w7//1000 + 3000 'random OFF time between 1 and 5 seconds
pause w8
High Up_Away
random w7
w8=w7//1000 + 3000 'random ON time between 1 and 5 seconds
pause w8
Low Up_Away
goto Waiting
Start1:
Waiting1:
do
let w3 =time
random w3
if Trigger = 1 then 'if pin on first picaxe goes high, run program
goto Swoop
endif
loop
Swoop:
High Side2Side
random w3
w4=w3//1000 + 5000 'random ON time between 1 and 5 seconds
pause w4
Low Side2Side
random w3
w4=w3//1000 + 3000 'random OFF time between 1 and 5 seconds
pause w4
High Side2Side
random w3
w4=w3//1000 + 5000 'random ON time between 1 and 5 seconds
pause w4
Low Side2Side
random w3
w4=w3//1000 + 3000 'random OFF time between 1 and 5 seconds
pause w4
High Side2Side
random w3
w4=w3//1000 + 3000 'random ON time between 1 and 5 seconds
pause w4
Low Side2Side
goto Waiting1
Start2:
Waiting2:
do
if Trigger = 1 then 'if pin on first picaxe goes high, run program
goto Shock_Awe
endif
loop
Shock_Awe:
High FX
Pause 14000
Low FX
goto Waiting2