How to control evive's buzzer in Arduino IDE
A piezo buzzer is an electronic device that is commonly used to produce sound. The working principle behind it is the inverse effect of piezoelectricity. Piezo electricity, or the piezo electric effect is the ability of certain materials to generate electric charge when mechanical pressure is applied on them. This effect was discovered by the French scientist brothers Jacques and Pierre Curie. The word Piezoelectric is derived from the Greek piezein, which means to squeeze or press, and piezo, which is Greek for push.
One of the notable features of the piezo electric effect is that it is reversible, meaning if an electrical field is applied to the object made of piezo electric material, mechanical stress is generated, i.e. it either stretches or compresses. These deformations leads to the generation of audible sound.
evive has an inbuilt piezo buzzer. The piezo buzzer is connected to digital pin 46 of Arduino Mega and is controlled via PWM.
Controlling Piezo Buzzer
To generate the electric signal from evive to control the buzzer, we use the tone() function. It generates a square wave of the specific frequency with a 50% duty cycle on digital pin 46. A different duty cycle can be specified otherwise. The wave continues until the noTone() function is called.
The frequency range is from 31 Hz to 65535 Hz.
tone(pin, frequency, duration)
- pin: the pin on which to generate the tone
- frequency: the frequency of the tone in hertz – unsigned int
- duration: the duration of the tone in milliseconds (optional) – unsigned long
Below are the Arduino IDE sketch showing how to use the piezo buzzer and play specific tones on Buzzer:
First example shows how to use tone() function. In this example different frequencies are played on buzzer.
In this example song of specific length is played on evive buzzer.
Controlling Servo Angle using Joystick in Arduino IDE
In this joystick Arduino servo tutorial, we will control the position of an RC (hobby) servo motor with a Joystick. evive has plug and play interface to control Servo for robotics. Servo motor Arduino code is also given in the content. This Tutorial also helps in building Arduino joystick servo control project.
How to configure the HC05 Bluetooth Module using AT Commands
This Arduino Uno Bluetooth module tutorial discusses what is Bluetooth, how does it work, the Arduino Bluetooth HC 05 code , How to connect Bluetooth module, and how to use the Bluetooth module with Arduino by the help of an Arduino sketch.(HC 05 Bluetooth module Arduino code is also given in the content)