We’re building out a pretty cool project, where we’re looking to build out a flat board that triggers playing/layering of audio (and potentially activating aromatisers, if it’s doable) depending on what part of the board you hold your hand over.
We’ve seen some examples from Bare Conductive (Interactive Wall Kit – Bare Conductive), but would love some advice on the parts we need to pull this together, especially if it’s Aussie-made!
We’re looking to ladder up and build an immersive way to enjoy a cocktail! This is for the World Championships of bartending in September - fun times!
Before I offer any thoughts can I clarify I’ve understood the idea.
Is the idea here that you can put the cocktail glasses on specific spots on your flat board to trigger audio?
Thanks! Our creative brains got a little ahead of our electrical ability for this one - ha!
Ideally we’d love for it to be something that they can hold the glass over, which increases in sensitivity (volume) as once it’s put down. If this gets too tricky, though, we’re very open to it being something that changes dependent on where its placed!
You got this! I do a lot of music art installations too, and I think it’s really healthy to give yourself permission to follow your creative ideas even if you don’t know how to achieve it. A good idea is a good idea.
What about magnets on the base of the cocktail glasses.
There is this thing called a Hall Effect Sensor which detects magnetic fields near by. If there was a magnet stuck on the bottom of the glass the sensor could detect it’s presence and distance. You can then map the distance of the magnet from the sensor to the volume of the music.
Have a look at this one.
It’s designed and supported by the staff at core electronics. You can daisy chain a whole bunch of these together and read it with the one small micro-controller. Additionally they have screws mounts so it’s easy to attach them under your flat-board. It’s all very plug-in and play.
Bonus points, you could get a magnetic ball bearing and use it as a whisky stone to “keep your booze nice and cool without watering it down”
If you don’t tell the audience how the magic is made, they will be shocked when they swirl their glass around and the music suddenly oscillates with the spinning of the ball bearing in the glass. Little touch; big impact.
This is awesome. Thank you very much for your help here!
I’m going to start to figure out the different bits I would need to make this happen, but LOVE the idea of swirling the glass and music oscillating! How good is that?!
I quite like @Pixmusix idea of the Magnetometer. It does allow for quite a bit of flexibility.
Another way of doing it would be using a distance sensor such as this Laser Distance Sensor.
This would allow an object like a hand to also work. It would mean that for a glass to work it may need the bottom of It to be covered so the laser can reflect off it.
An option that could work if the sensor is mounted overhead could be an Ultrasonic Distance Senor. It would have the same benefit of working with any object. However, I would advise against putting them below the users as they may not work well if a drink gets spilled on the sensor.
this I think is the way I’ve seen hall effect sensors used in drink dispensing units… and I love the idea of the metal being inside of ice replacement /whiskey stones -super cute.
What a fun project. There are some cool suggestions already being tossed about. The magnetometer is my favourite so far. There are just so many different ways you could implement even a pair of them.
The field may also be subject to a little bit of noise that will make it harder for your audience to work out how exactly it works.
So, we’ve run into some fairly frustrating issues - namely to do with the code.
We had this one written for us:
import time
from PiicoDev_QMC6310 import PiicoDev_QMC6310
from pygame import mixer
import smbus2
# Initialize the mixer for audio playback
mixer.init()
# Audio files to be played
audio1 = "/home/worldclass/Documents/VirtualEnvironment/audio1.m4a"
audio2 = "/home/worldclass/Documents/VirtualEnvironment/audio2.m4a"
# Initialize the multiplexer address and channels
MUX_ADDRESS = 0x70
CHANNEL_1 = 0x01
CHANNEL_2 = 0x02
# Initialize I2C bus
bus = smbus2.SMBus(1)
# Function to select a channel on the multiplexer
def select_channel(channel):
bus.write_byte(MUX_ADDRESS, channel)
time.sleep(0.1) # Small delay to ensure the channel is selected
# Initialize magnetometers on their respective channels
select_channel(CHANNEL_1)
mag1 = PiicoDev_QMC6310(bus=bus)
select_channel(CHANNEL_2)
mag2 = PiicoDev_QMC6310(bus=bus)
# Function to calculate the magnet's proximity based on magnetometer readings
def get_proximity(mag1, mag2):
reading1 = mag1.read_magnet()
reading2 = mag2.read_magnet()
# Here, we'll use a simple comparison of the magnetometer readings
if reading1 > reading2:
return 1 # Closer to sensor 1
elif reading2 > reading1:
return 2 # Closer to sensor 2
else:
return 0 # In between
# Function to play audio based on proximity
def play_audio(proximity):
if proximity == 1:
mixer.music.load(audio1)
mixer.music.play()
elif proximity == 2:
mixer.music.load(audio2)
mixer.music.play()
else:
# Mix both audios if the magnet is in between
mixer.music.load(audio1)
mixer.music.play()
time.sleep(0.5)
mixer.music.load(audio2)
mixer.music.play()
try:
while True:
proximity = get_proximity(mag1, mag2)
play_audio(proximity)
time.sleep(1)
except KeyboardInterrupt:
mixer.music.stop()
print("Program stopped.")
And every time we try and run it we get this error:
pygame 2.1.2 (SDL 2.26.5, Python 3.11.2)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
File "/home/worldclass/Documents/VirtualEnvironment/magnetreader.py", line 19, in <module>
bus = smbus2.SMBus(1)
File "/usr/lib/python3/dist-packages/smbus2/smbus2.py", line 280, in __init__
self.open(bus)
File "/usr/lib/python3/dist-packages/smbus2/smbus2.py", line 310, in open
self.fd = os.open(filepath, os.O_RDWR)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/i2c-1'
>>>
We figure that we are missing a piece of hardware, but really just want to daisy chain 3-4 magnetometers together and toggle the different sounds based on the magnetic fields (z being the main one to measure).
You haven’t provided much detail about the hardware, but I think the code is telling you that i2c-1 isn’t available. Have you configured your hardware for i2c-1?