Git Product home page Git Product logo

sonic_volume's Introduction

Raspberry Pi 3 :: Sonic Volume Adjustment ๐Ÿ”Š

A little RPi3 project. Having some fun with RPi3, sensors and ES6/Node.js

Breadboard / Wiring / Physics / Math

Fritzing

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)

Components closer look: T-Cobbler & Breadboard Ultrasonic Ranging Sensor Dual-Colour LED

Usage

# 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! :)

Links

Radio Stations

tunein.com

shoutcast.com

radio.net

Semantic Commits

sonic_volume's People

Contributors

smileart avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.