getting an early jump on a Halloween project

Pat13

Senior Member
Hi all. Since my last Halloween picaxe project turned into the Nightmare on Howe Place (but actually ran flawlessly on the Big Night), I thought I would get a jump on this year's project. It entails 3 witches having a "conversation", using an 18M2 and 3 Tenda mp3 boards. The witches will all chant together, then have the picaxe randomly select one of seven chants, of which they will each say a line. The 18M2 will use the RX line on the Tendas' to send commands and will monitor the "Busy" line on the Tendas' to signal when to move to the next section of code. Here is the preliminary code, it is incomplete (does not have the "random" section yet, nor all seven chants) and I have not downloaded it into an 18M2 yet. However, I have run syntax on it and am coming up with an error on the line "if Aggie_BZ = 1 then". I'm not sure why that is, as I have used almost an exact version of that line in another code and had no such error.

Code:
'18M2 Picaxe control for multiple Tenda boards for Witch conversations

symbol Aggie = B.0 'Tenda 1 RX
symbol Gertie = B.2 'Tenda 2 RX
symbol Brunny = B.4 'Tenda 3 RX
symbol Aggie_BZ = B.1 'Tenda 1 Busy
symbol Gertie_BZ =B.3 'Tenda 2 busy
symbol Brunny_BZ = B.5 'Tenda 3 Busy
symbol Baud =T4800 'tenda baud Rate
symbol Trigger =C.1 'trigger, probably PIR
symbol debounce = b1

	Init:					'starting point
		serout Aggie, Baud, ($EF) 'stop tenda 1
		serout Gertie, Baud, ($EF)'stop tenda 2
		serout Brunny, Baud, ($EF)'stop tenda 3
		pause 10000			'wait 10 seconds
		serout Aggie, Baud, ($E8) 'set tenda 1 volume
		serout Gertie, Baud, ($E8) 'set tenda 2 volume
		serout Brunny, Baud, ($E8) 'set tenda 3 volume
		pause 60000	 'wait 1 minute 
		
	Cauldron:	serout Aggie, BAUD, ($E8)           'set Tenda volume
		debounce=0
		Do
			serout Aggie, Baud, ($02)  `play Track 2, Folder 1
				pause 1000                    'give Tenda time to start playing track
			if Aggie_BZ  =  1 then All_Chant              '0=playing, 1=stopped
			endif
			readadc Trigger,debounce 
		Loop While debounce<50              ' exit loop if PIR triggered
	
	All_Chant:
			pause 500
			serout Aggie, Baud, ($01)
			serout Gertie, Baud, ($01)
			serout Brunny, Baud, ($01)
			pause 1000
			Do while Aggie_BZ = 0 
			loop
	Early_Early:
			serout Aggie, Baud ($F2,01)
			pause 1000
			do while Aggie_BZ = 0
			loop
			
			serout Gertie, Baud ($F2,01)
			pause 1000
			do while Gertie_BZ = 0
			loop
			
			serout Aggie, Baud ($F2,02)
			pause 1000
			do while Aggie_BZ = 0
			loop
			
			serout Gertie, Baud ($F2,02)
			pause 1000
			do while Gertie_BZ = 0
			loop
			
			
			serout Aggie, Baud ($F2,03)
			pause 1000
			do while Aggie_BZ = 0
			loop
			
			serout Gertie, Baud ($F2,03)
			pause 1000
			do while Gertie_BZ = 0
			loop
			
			serout Aggie, Baud ($F2,04)
			pause 1000
			do while Aggie_BZ = 0
			loop
			
			serout Gertie, Baud ($F2,04)
			pause 1000
			do while Gertie_BZ = 0
			loop
I am unsure of a couple of things, how to generate the random choosing of the verses ( I know how to generate random pause times, not sure how that would apply to whole sections of code) and where to insert it into the code. Any suggestions greatly appreciated.
 

Pat13

Senior Member
symbol Aggie_BZ = pinB.1 'Tenda 1 Busy

same required for the other inputs
Thanks westaust55, that would have been one of those things I would have pulled my hair out trying to figure out

Have you seen the random command?
Yes nick12ab, I have used it, although not with "timer". I was thinking I could use modulus to choose between 1 and 7, then assign 1 thru 7 to verse sections (such as Early_Early in the above code) using the if/then command.
 

pleiser

Senior Member
completly off topic, but reminds me of a costume I made last year (a robot with an lcd screen), I impressed all the neighbors with it (except 50% of the time when a jumper wire fell out of the breadboard;)
 
Top