The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA] by lallo

View this thread on steempeak.com
· @lallo · (edited)
$3.66
The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA]
[ENG]

Today I want to show you a small project I made with Arduino. For those who don't know, Arduino is a microcontroller, that is a small electronic card that is able to communicate with sensors, turn LEDs on or off, operate motors, etc etc; on which it is possible to load programs written with the Arduino programming language. With it it is therefore possible to make an electronic device interact with the outside world and make prototypes of all kinds, it is only necessary to have creativity and imagination (as well as obviously a little knowledge about electrical circuits and programming).
In my case I wanted to create a simple musical instrument similar to the one used by Pink Floyd, which emits notes based on the distance an object is placed from it. The farther the object is, the lower the frequency will be and the closer it is, the higher it will be. To measure the distance I used an ultrasonic sensor HC-SR04 compatible with Arduino and to emit sounds I took a small speaker recovered from an old cordless phone.

[ITA]

Oggi vi voglio far vedere un piccolo progetto che ho realizzato con Arduino. Per chi non lo sapesse Arduino è un microcontrollore, cioè una piccola scheda elettronica che è in grado di comunicare con dei sensori, accendere o spegnere dei led, azionare dei motori, ecc ecc; sul quale è possibile caricare dei programmi scritti con il linguaggio di programmazione di Arduino. Con esso è possibile dunque far interagire un apparato elettronico con il mondo esterno e realizzare prototipi di ogni tipo, bisogna solo avere creatività e immaginazione (oltre ovviamente ad una infarinata di conoscenze riguardo ai circuiti elettrici e alla programmazione).
Nel mio caso ho voluto realizzare un semplice strumento musicale simile a quello usato dai Pink Floyd, che emette delle note in base alla distanza a cui viene posto un oggetto da esso. Più l'oggetto è lontano e più la nota sarà di bassa frequenza, viceversa più sarà vicino e più sarà alta. Per misurare la distanza ho utilizzato un sensore ad ultrasuoni HC-SR04 compatibile con Arduino e per emettere i suoni ho preso una piccola cassa recuperata da un vecchio telefono cordless. 
![strume.jpg](https://ipfs.busy.org/ipfs/QmV9d9dmRr4eHDR4Qzbbm7xjMAr9e92Gxw7JJDvovBuQCk)

[ENG]

Its operation is very simple, in practice once an object passes in front of the sensor, it calculates the distance (the sensor continuously shoots ultrasound waves and waits for them to return by timing the time taken to return them, and takes the distance), communicates it to Arduino, which thanks to a function that I inserted in the program calculates the frequency relative to that distance and sends the signal to the speaker, which starts ringing at that frequency.
For technical reasons I set 622 Hz as the highest frequency, which should correspond to a D# of 5° octave and as a maximum distance of 1 meter, so that when the object is at a distance of 1 meter, the instrument plays the note lower and vice versa the higher note at a distance of 5 cm. Therefore the instrument will be able to emit frequencies from values ​​close to zero up to 622 Hz in an approximately continuous manner, so it will be able to emit sounds comprised between the traditional notes and not simply the common C, C#, D, D#, E, etc. etc., but every little intermediate micro-variation.
For better clarity, I invite you to see this demonstration video I made to show you how it works.
Good vision!

[ITA]

Il suo funzionamento è molto semplice, in pratica una volta che un oggetto passa davanti al sensore, quest'ultimo ne calcola la distanza (il sensore spara continuamente onde ad ultrasuoni e aspetta il loro ritorno cronometrando il tempo impiegato da queste per tornare, e ne ricava la distanza), la comunica ad Arduino, il quale grazie ad una funzione che ho inserito nel programma calcola la frequenza relativa a quella distanza e invia il segnale alla cassa, la quale inizia a suonare a quella frequenza.
Per ragioni tecniche ho impostato come frequenza più alta 622 Hz che dovrebbe corrispondere ad un RE# di 5° ottava e come massima distanza 1 metro, in modo tale che quando l'oggetto si trova ad un 1 metro di distanza lo strumento suoni la nota più bassa e viceversa la nota più alta ad una distanza di 5 cm. Quindi lo strumento sarà in grado di emettere frequenze da valori prossimi allo zero fino a 622 Hz in maniera approssimativamente continua, cioè potrà emettere suoni compresi tra le note tradizionali e non semplicemente le comuni Do, Do#, RE, RE#,MI , ecc ecc, ma ogni piccola microvariazione intermedia.
Per migliore chiarezza vi invito a vedere questo video dimostrativo che ho realizzato per mostrarvi il suo funzionamento.
Buona visione!

<center><a href='https://d.tube/#!/v/lallo/4ifjsi42'><img src='https://ipfs.io/ipfs/QmTRe2XnqNM1Y9tGNf7q9mLp12q6Ba9pZUYQBqsND8yju3'></a></center><hr>

Now below I leave the code written in the Arduino language that I used to make this nice musical instrument that I called "The Sonic Instrument" :)
Comments are written after the // symbol and the function tone(pin, frequency) is the one that sends the electrical signal to the case connected to Arduino pin 2 at the desired frequency.

Ora qui sotto vi lascio il codice scritto nel linguaggio di Arduino che ho utilizzato per fare questo simpatico strumento musicale che ho chiamato " Lo Strumento Sonico " :)
I commenti sono scritti dopo il simbolo //  e la funzione tone(pin,frequenza) è quella che invia il segnale elettrico alla cassa connessa al pin 2 di Arduino alla frequenza desiderata.

#define echoPin 7 // Echo Pin is connected to the pin 7 - Il pin dell' Echo è connesso con il pin 7
#define trigPin 8 // Trigger Pin is connected to the pin 8 - Il pin del Trigger è connesso con il pin 8

int maximumRange = 100; // Maximum range 100 cm - Distanza massima 100 cm
double duration, distance; // Duration used to calculate distance - La durata è usata per calcolare la distanza

void setup() {
 pinMode(trigPin, OUTPUT); //set trigPin in output modality - Imposta il pin trigger in modalità output
 pinMode(echoPin, INPUT); //set echoPin in input modality - Imposta il pin echo in modalità input
 pinMode(2,OUTPUT); // set pin 2 in output mod. to send electric signal to the speaker - Imposta il pin 2 in modalità output per inviare segnali elettrici alla cassa
}
// The following trigPin/echoPin cycle is used to determine the distance of the nearest object by bouncing //soundwaves off of it. 
//Il ciclo seguente è usato per determinare la distanza dell'oggetto più vicino sparando onde sonore contro di //esso 
void loop() { 
 digitalWrite(trigPin, LOW); 
 delayMicroseconds(2); 
 digitalWrite(trigPin, HIGH);
 delayMicroseconds(10); 
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = duration/58.2;
 if(distance < maximumRange) {
  tone(2, 622-((distance-5)*6.56 ));    //Play all the micro variations of frequence between 0 and 622 Hz - Suona tutte le microvariazioni di frequenza comprese tra 0 e 622 Hz
 }
 else {
  noTone(2);
 }
 delay(66);
}

Here is also the circuit diagram where apart from the sensor and the 165 Ohm speaker, I used a 350 Ohm resistance, making a current of about 9.7 mA circulate inside the circuit, widely tolerated by Arduino that has a tolerance maximum of 40 mA for each digital pin. (The voltage on the pins is 5V)

Ecco anche lo schema del circuito dove apparte il sensore e la cassa da 165 Ohm ho utilizzato una resistenza da 350 Ohm circa, facendo circolare all'interno del circuito una corrente di circa 9,7 milli Ampere, ampiamente tollerata da Arduino che ha una tolleranza massima di 40 milli Ampere per ogni singolo pin digitale. (La tensione sui pin è di 5V)
![stume.jpg](https://cdn.steemitimages.com/DQmY26jZexhUo4ceFG2Ccq4i1ydUG6L39tyxt63zNdnUYr4/stume.jpg)
#### Image created by me with Fritzing - Immagine da me creata con Fritzing
<br>
I hope this post was to your liking, thanks for stopping by to read it, later I will show you another project made with Arduino.
Goodbye see you soon :)

Spero che questo post sia stato di vostro gradimento, grazie per esservi fermati a leggerlo, più avanti vi mostrerò un'altro progetto realizzato sempre con Arduino.
Ciao alla prossima :)

Sources - Fonti : 
http://blog.whatgeek.com.pt/arduino/arduino-hc-sr04-ultrasonic-sensor/
https://www.critics-corporation.com/RaspberryPi/come-usare-sensore-ultrasuoni-hc-sr04-con-arduino
https://www.arduino.cc/reference/en/language/functions/advanced-io/tone/


<hr><a href='https://d.tube/#!/v/lallo/4ifjsi42'> ▶️ DTube</a><br /><a href='https://ipfs.io/ipfs/Qmd5boZCWudxg1CeL7pYjhtkdaXYWsdFkXpmRAF4CSrJU8'> ▶️ IPFS</a>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 467 others
properties (23)
post_id71,481,052
authorlallo
permlink4ifjsi42
categorydtube
json_metadata"{"video":{"info":{"title":"The Sonic Instrument - Lo Strumento Sonico (Arduino project\/English sub) [ENG\/ITA]","snaphash":"QmPc24s2eTYoWwU6LFq5CMXgZv87vLEaQR7NhCsARLB1VW","author":"lallo","permlink":"4ifjsi42","duration":132.394666,"filesize":103817859,"spritehash":"QmdX65YozS6B6pmejNaFd7U6SdDUc619bjrPhLagrAWrZ6"},"content":{"videohash":"Qmd5boZCWudxg1CeL7pYjhtkdaXYWsdFkXpmRAF4CSrJU8","description":"This is a dimonstration of my little project on Arduino...enjoy the video\nFor more details have a look on the associated Steemit post","tags":["technology","tutorial","arduino","ita"],"video240hash":"QmT5Qe6P4uHndR8dZsZcMjRN54LDVD7C7obGLBq8JahRgf","video480hash":"Qme2LGVmNHN8hF5PEy7MT67t3DLCWftceoxAKoJHq8GmnB"}},"tags":["dtube","technology","tutorial","arduino","ita"],"app":"steemit\/0.1","community":"SteemPostItalia","format":"markdown","links":["https:\/\/d.tube\/#!\/v\/lallo\/4ifjsi42","http:\/\/blog.whatgeek.com.pt\/arduino\/arduino-hc-sr04-ultrasonic-sensor\/","https:\/\/www.critics-corporation.com\/RaspberryPi\/come-usare-sensore-ultrasuoni-hc-sr04-con-arduino","https:\/\/www.arduino.cc\/reference\/en\/language\/functions\/advanced-io\/tone\/","https:\/\/ipfs.io\/ipfs\/Qmd5boZCWudxg1CeL7pYjhtkdaXYWsdFkXpmRAF4CSrJU8"],"image":["https:\/\/ipfs.busy.org\/ipfs\/QmV9d9dmRr4eHDR4Qzbbm7xjMAr9e92Gxw7JJDvovBuQCk","https:\/\/ipfs.io\/ipfs\/QmTRe2XnqNM1Y9tGNf7q9mLp12q6Ba9pZUYQBqsND8yju3","https:\/\/cdn.steemitimages.com\/DQmY26jZexhUo4ceFG2Ccq4i1ydUG6L39tyxt63zNdnUYr4\/stume.jpg"]}"
created2019-03-14 23:40:51
last_update2019-03-16 01:02:42
depth0
children8
net_rshares5,870,978,876,423
last_payout2019-03-21 23:40:51
cashout_time1969-12-31 23:59:59
total_payout_value2.732 SBD
curator_payout_value0.923 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length8,661
author_reputation8,754,316,063,692
root_title"The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA]"
beneficiaries
0.
accountdtube
weight1,000
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (531)
@tibfox ·
u6801xzud
I have built something similar some years ago :) I love the ultrasonic sensors for these touch kind of feeling! I really want to see more of you here :) followed

Thanks for sharing this #awesomediycontent with us! It was really educating and interesting to see that you built the same thing as me :) only difference is that I didn't used a breadboard and I used it as a midi instrument for a DAW :) you can use the midi library and a combination of a virtual midi driver to control midi instruments in the next step if you want to continue on this project :) 

## Peace!
properties (22)
post_id71,482,533
authortibfox
permlinku6801xzud
categorydtube
json_metadata{"app":"dtube\/0.8"}
created2019-03-15 00:12:12
last_update2019-03-15 00:12:12
depth1
children2
net_rshares0
last_payout2019-03-22 00:12:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length571
author_reputation98,728,933,224,085
root_title"The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA]"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@lallo ·
$0.04
Oh that's awesome, the world is really small!! I wish to see your project!! Thanks for your tip I will take it in account. Here I wanted to create the simplest program possible just to experiment with sound and to have fun :) I also tried to create a mini amplifier to get a better and load sound, using some transistor but was easy at all. I managed just to raise the volume but I got a distorced noisy sound. Maybe one day I will take inspiration from some existing circuit.
Bye bye thanks for your support...have a good day :)
👍  ,
properties (23)
post_id71,483,240
authorlallo
permlinkre-tibfox-u6801xzud-20190315t002448028z
categorydtube
json_metadata{"tags":["dtube"],"app":"steemit\/0.1"}
created2019-03-15 00:28:27
last_update2019-03-15 00:28:27
depth2
children1
net_rshares62,264,311,118
last_payout2019-03-22 00:28:27
cashout_time1969-12-31 23:59:59
total_payout_value0.031 SBD
curator_payout_value0.010 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length529
author_reputation8,754,316,063,692
root_title"The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA]"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (2)
@tibfox ·
It was some years ago and unfortunately I don't have the little box anymore. But yeah.. it was quiet easy with all these well documented libraries :) 

Keep going! 
## Peace!
properties (22)
post_id71,519,177
authortibfox
permlinkre-lallo-re-tibfox-u6801xzud-20190315t182737042z
categorydtube
json_metadata{"tags":["dtube"],"app":"steemit\/0.1"}
created2019-03-15 18:27:36
last_update2019-03-15 18:27:36
depth3
children0
net_rshares0
last_payout2019-03-22 18:27:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length174
author_reputation98,728,933,224,085
root_title"The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA]"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@diytube ·
<center><h2>Thanks a lot for your creative, inspiring and motivating video!</h2>
</center>

<div class="pull-right"><img src="https://steemitimages.com/p/KWcVEiwEzuiFFPwDMgX8R12Kejff18PnuYhnNdq9ZU4qFgkCob6FLBLo7QaNm1jBZeSqoAPCWeomkwsVVG?format=match&mode=fit&width=320"></div>

This post got curated by our fellow curator @tibfox and you received a >90% upvote from our **non-profit** curation service!

**Feel free to check out our channel @diytube to:**
- find more information about the service
- join the curation team and support this initiative

<center>*This service is part of the Global Homesteading Collective 
@ghscollective*</center>
properties (22)
post_id71,482,907
authordiytube
permlinkre-4ifjsi42-20190315t002005z
categorydtube
json_metadata{"app":"beem\/0.20.14"}
created2019-03-15 00:20:06
last_update2019-03-15 00:20:06
depth1
children0
net_rshares0
last_payout2019-03-22 00:20:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length645
author_reputation4,973,552,042,191
root_title"The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA]"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steem-plus ·
SteemPlus upvote
Hi, @lallo!

You just got a **0.44%** upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in [here](https://steemit.com/@steem-plus) to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.
properties (22)
post_id71,522,354
authorsteem-plus
permlink4ifjsi42---vote-steemplus
categorydtube
json_metadata{}
created2019-03-15 19:44:21
last_update2019-03-15 19:44:21
depth1
children0
net_rshares0
last_payout2019-03-22 19:44:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length432
author_reputation247,995,867,762,997
root_title"The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA]"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steemstem ·
re-lallo-4ifjsi42-20190315t222321166z
<div class='text-justify'> <div class='pull-left'> <br /> <center> <img width='125' src='https://i.postimg.cc/9FwhnG3w/steemstem_curie.png'> </center>  <br/> </div> <br /> <br /> 

 This post has been voted on by the **SteemSTEM** curation team and voting trail in collaboration with **@curie**. <br /> 
 If you appreciate the work we are doing then consider [voting](https://www.steemit.com/~witnesses) both projects for witness by selecting [**stem.witness**](https://steemconnect.com/sign/account_witness_vote?approve=1&witness=stem.witness) and [**curie**](https://steemconnect.com/sign/account_witness_vote?approve=1&witness=curie)! <br /> 
For additional information please join us on the [**SteemSTEM discord**]( https://discord.gg/BPARaqn) and to get to know the rest of the community! </div>
properties (22)
post_id71,527,814
authorsteemstem
permlinkre-lallo-4ifjsi42-20190315t222321166z
categorydtube
json_metadata{"app":"bloguable-bot"}
created2019-03-15 22:23:24
last_update2019-03-15 22:23:24
depth1
children0
net_rshares0
last_payout2019-03-22 22:23:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length800
author_reputation229,673,617,633,863
root_title"The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA]"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@discovery-it ·
<div class="pull-left">https://cdn.steemitimages.com/DQmTujwfNcnEpp8WRU1Guj8kaUjWuxwsyQcFqKwJ1cZNCkT/discovery_logo_verde_200x200_trasparente.png</div><br>Questo post è stato condiviso e votato dal team di curatori di <a href="https://discord.gg/cMMp943"> discovery-it</a>.<hr>.
properties (22)
post_id71,547,040
authordiscovery-it
permlinkre-lallo-4ifjsi42-20190316t081233353z
categorydtube
json_metadata{"community":"busy","app":"busy\/2.5.6","format":"markdown","tags":["dtube"],"users":[],"links":["https:\/\/discord.gg\/cMMp943"],"image":["https:\/\/cdn.steemitimages.com\/DQmTujwfNcnEpp8WRU1Guj8kaUjWuxwsyQcFqKwJ1cZNCkT\/discovery_logo_verde_200x200_trasparente.png"]}
created2019-03-16 08:12:36
last_update2019-03-16 08:12:36
depth1
children0
net_rshares0
last_payout2019-03-23 08:12:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length278
author_reputation5,843,414,133,735
root_title"The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA]"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@steemitboard ·
Congratulations @lallo! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

<table><tr><td>https://steemitimages.com/60x70/http://steemitboard.com/@lallo/votes.png?201903220932</td><td>You made more than 1250 upvotes. Your next target is to reach 1500 upvotes.</td></tr>
</table>

<sub>_You can view [your badges on your Steem Board](https://steemitboard.com/@lallo) and compare to others on the [Steem Ranking](http://steemitboard.com/ranking/index.php?name=lallo)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Do not miss the last post from @steemitboard:**
<table><tr><td><a href="https://steemit.com/carnival/@steemitboard/carnival-challenge-here-are-the-winners"><img src="https://steemitimages.com/64x128/http://i.cubeupload.com/rltzHT.png"></a></td><td><a href="https://steemit.com/carnival/@steemitboard/carnival-challenge-here-are-the-winners">Carnival Challenge - Here are the winners</a></td></tr></table>

> You can upvote this notification to help all Steem users. Learn how [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!
properties (22)
post_id71,845,671
authorsteemitboard
permlinksteemitboard-notify-lallo-20190322t102314000z
categorydtube
json_metadata{"image":["https:\/\/steemitboard.com\/img\/notify.png"]}
created2019-03-22 10:23:15
last_update2019-03-22 10:23:15
depth1
children0
net_rshares0
last_payout2019-03-29 10:23:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length1,207
author_reputation38,705,954,145,809
root_title"The Sonic Instrument - Lo Strumento Sonico (Arduino project/English sub) [ENG/ITA]"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000