Challenge šŸ”ŠšŸ”ŠWrite code for arduino: the volume and frequency and beeping of a piezo buzzer increases when the....(description) | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

Challenge šŸ”ŠšŸ”ŠWrite code for arduino: the volume and frequency and beeping of a piezo buzzer increases when the....(description)

.... object comes nearer to the proximity sensor and also the vibrator motor will follow the same sequence with the piezo buzzer.(the sensor is four pin HC-SRO4)and also add a push button to start the circuit.

10th Oct 2017, 5:14 AM
Sandim Kaushik
Sandim Kaushik - avatar
22 Respostas
+ 4
NEVER WIRE ANY MOTOR DIRECTLY TO YOUR ARDUINO PIN: YOU WILL PROBABLY FRY YOUR ARDUINO IF YOU DO SO. the motor driver is only a buffer between the MCU and the motor that would otherwise fry your ATmega chip by absorbing a current (amps) that the chip is not able to supply. Absolute Max limitations of an arduino are 40mAh (milliamps) per pin and 200mAh totally (using multiple pins). A stalled motor absorbs inthe range of Amps usually resulting in a fried Arduino A motor driver board allows you to control with logic level signals, the polarity of large loads (like motors) For what you want to do, you don't need a motor driver board: a tip120 or other logic level mosfet will do the Job. For small motors (like handphone vibrators) a 2n222 transistor will also do the job. See the wiring and the code here. Again oomlout tutorials that you shuold read before you fry someything. http://www.oomlout.com/oom.php/products/ardx/circ-03 To regulate the speed of the motor you'll have to adjust the PWM signal using analogWrite(pinNumber, thevspeed as a numeric value between 0 and 255). example analogWrite(13, 180); Practically speaking, the same way you fade an LED. https://www.arduino.cc/en/Tutorial/PWM
13th Oct 2017, 4:33 PM
seamiki
seamiki - avatar
+ 2
https://www.arduino.cc/en/Reference/Map The detectable distance ranges from 10cm to 400cm (tune the values for your sensor) Your usable frequency (assuming youā€™re using an UNO board) ranges from 31Hz to 65535Hz map function is used to do get a value in frequency, proportional to the distance measured
12th Oct 2017, 1:03 AM
seamiki
seamiki - avatar
+ 2
sorry but i don't use the email. My suggestion: internet is filled with arduino examples. A nice set of beginner friendly circuits and codes, comes with the oomlout kit: http://oomlout.com/a/products/ardx/ (no need to buy anything: just use what you already have and what can be scavanged from old electronics). For libraries and a bit more advanced stuff refere to the Arduino reference https://www.arduino.cc/en/Reference/HomePage do your homework and you'll find out that everything is simplier than you think.
12th Oct 2017, 1:35 AM
seamiki
seamiki - avatar
+ 2
Again, take a look and practice with the examples of the oomlout kit. Once you have them working, tweak the code to see how your changes affect the behavior of the microcontroller. Internet is full of tutorials telling you that yuo need to buy stuff: fon't do it. Get first a grip on the simple stuff and for that you can scavange components from an old PC/radio/printer/dvdplayer....
12th Oct 2017, 2:06 AM
seamiki
seamiki - avatar
+ 2
Final advice: pls don't call me "sir";-)
12th Oct 2017, 4:51 AM
seamiki
seamiki - avatar
+ 2
Pls read the pages i linked you: everything you need is in there: 1 reading distance 2 playing a tone 3 mapping values If your challenged by the 3 tasks together, divide your challenge in 3 simplier and separate programs and, when you are confident about every line of code, combine them in a single program. Good luck with your challenge.
12th Oct 2017, 5:32 PM
seamiki
seamiki - avatar
+ 1
use the Ping and the Tone library in the loop check the button input to set a boolean flag. if the flag is true execute the code in the loop measure distance store distance set volume frequency accordingly play tone move motor delay(better if using millis with another flag) stop playing tone stop motor
10th Oct 2017, 7:57 AM
seamiki
seamiki - avatar
+ 1
if (digitalRead(inputButtonPin)==HIGH){ executeCode = true; } /*start measuring soundingband vibrating only aftervthe button is pressed*/ if (executeCode){ ping.fire(); frequency = map(pingCentimeters, 0, maxDistance, maxFreq, minFreq); /*for the volume you may want to look at the pitch instead since your analog outputs are actually pwm*/ //start motor digitalWrite(motorPin, HIGH); //play tone tone(buzzerPin, frequency, duration); //stop motor digitalWrite(motorPinLow); } that's a hint for what should be in the loop i'll leave to you how ro figure out the setup and the global variables. Below are the links to the tone and ping library pages with reference and examples. https://www.arduino.cc/en/Reference/Tone https://playground.arduino.cc/Code/Ping
11th Oct 2017, 6:29 AM
seamiki
seamiki - avatar
+ 1
use speed =map(freq, minFreq, maxFreq, 0, 255); pls read the pages i linked you in the previous posts.
14th Oct 2017, 6:26 AM
seamiki
seamiki - avatar
+ 1
Yes analogWrite. avoid using delay() as it "freezes" the whole microcontroller affecting eventually also the distance readings. start the motor play the tone stop the motor you do not need delays
14th Oct 2017, 1:11 PM
seamiki
seamiki - avatar
0
bro can you give the exact code
11th Oct 2017, 3:08 AM
Sandim Kaushik
Sandim Kaushik - avatar
0
you can choose any pin on the arduino
11th Oct 2017, 4:31 AM
Sandim Kaushik
Sandim Kaushik - avatar
0
is (map) a variable in the code or is it a function
11th Oct 2017, 1:11 PM
Sandim Kaushik
Sandim Kaushik - avatar
0
stay in touch to discuss
11th Oct 2017, 6:06 PM
Sandim Kaushik
Sandim Kaushik - avatar
0
please explain the map
11th Oct 2017, 6:06 PM
Sandim Kaushik
Sandim Kaushik - avatar
0
here is my email so that we can discuss dipkaushik12@gmail.com
12th Oct 2017, 1:25 AM
Sandim Kaushik
Sandim Kaushik - avatar
0
sir stay in touch I am a 13 yr old and I will need ur guidance
12th Oct 2017, 1:42 AM
Sandim Kaushik
Sandim Kaushik - avatar
0
Bro pls can u declare the all the variables
12th Oct 2017, 5:17 PM
Sandim Kaushik
Sandim Kaushik - avatar
0
Is there any way to increase the rpm of the motor when any object come nearer ( without motor driver )
13th Oct 2017, 3:31 PM
Sandim Kaushik
Sandim Kaushik - avatar
0
bro how to match the acceleration of the motor to the frequency of the buzzer
14th Oct 2017, 5:59 AM
Sandim Kaushik
Sandim Kaushik - avatar