Forum

Can I trigger more sounds using a serial port or use several pins @ once?

More
#11 by rudydevolder
rudydevolder created the topic: Can I trigger more sounds using a serial port or use several pins @ once?
Serial via SPI, I2C or UART? :dry:
Or using a binary code on several pins at once with a trigger input and than decode? :huh: For example
P1.3 + P1.2 + P1.1 + P1.0 + P2.3 + P2.2 + P2.1 + P2.0 + trigger P6.3 ( = 8 bits => 256 combinations or sounds )

A programming example would be nice :P

Please Log in or Create an account to join the conversation.

More
#14 by foxonix
foxonix replied the topic: Can I trigger more sounds using a serial port or use several pins @ once?
Yes, you can read an entire port at once and store it in a register using the Mi=Pn command. For example, the command M2=P1 will read port P1 and store the value in register M2. You can then decode the value in the register and use it to call up to 16 different labels. The code looks like this:

& M2=P1				; read P1 and store value in M2		
& M2:[label0 label1 label2]	; decode the value and jump to that label in the array

label0:
	& soundfile0.wav
	& end

label1:
	& soundfile1.wav
	& end

label2:
	& soundfile2.wav
	& end

If port P1 is 0000, then label0 will be called and soundfile0.wav will play.
If port P1 is 0001, then label1 will be called and soundfile1.wav will play, and so on.

This can be expanded to decode more inputs, but would need to be done in multiple steps. We can put together a sample program and post it.

Foxonix - make your ideas heard.
@foxonixdev

Please Log in or Create an account to join the conversation.

Time to create page: 0.023 seconds