A little RPi3 project. Having some fun with RPi3, sensors and ES6/Node.js
Basically, these are two components: Dual-Colour LED + Ultrasonic Ranging Sensor wired together. LED colours mix (red & green) and brightness controlled by PWM, Ultrasonic Ranging Module sends sound impulses and gets the echo (low level) so knowing the time difference between sending and receiving signal we could calculate the distance distance = (high level time * velocity of sound) / 2
(*1) (actually the speed of sound depends on the air temperature [and other factors], but for purposes of simplicity I assume that it is a constant - 343.59 m/s, as for 20ยฐC). After calculating the distance we have to convert the number of cm
to the dB
in range accepted by amixer command (in our case -2400 โ 400 for -24dB - 4dB). To do so I'll use Range Mapping implemented in linear-conversion library. And as the result we call a shell command amixer cset numid=1 -- <volume>
setting the output volume of the speaker connected through 3.5mm stereo jack. And voilร : you've got yourself a sonic volume adjustment system.
(*1) Constant 2 here means sound does a double path (from and than back to the module, being reflected from the obstacle)
# First: Run mplayer with any station (See: Links)
mplayer -playlist http://s7.nexuscast.com/tunein/247christmasheaven.pls
# Second: run the script. Note the sudo:
sudo node index.js
# Third: adjust the volume with your hand (~ 30cm above the sensor)
# Option 1: wave on desired height
# Option 2: put your hand above the sensor and move it up & down
#
# DONE! :)
Radio Stations
Semantic Commits