This project is created as a part of the Bolt Internet of things and Machine Learning training. In this project, using the PULSE WIDTH MODULATION the intensity of buzzer sound can be varied. Pulse width modulation is used in a variety of applications including sophisticated control circuitry.
STEP 1: Circuit Connections:
- Insert the negative leg of buzzer into the ground pin of Bolt Wifi Module
- Insert the Positive leg of buzzer into A0 pin.
STEP 2: Creating a python program.
- After completing the hardware connections, log into your ubuntu virtual machine.
- Now create a python file.
sudo nano buzzer_control.py
- And type the code show below into the virtual machine.
from boltiot import Bolt
api_key = "92aXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
device_id = "BOLT31XXXX"
mybolt = Bolt(api_key, device_id)
response = mybolt.analogWrite('0', '10')
print (response)
- In the first line, we are importing the Bolt class from the boltiot module and then we assigning the api_key which you will get on Bolt cloud which is unique for every user.
- In third line, you need to assign the device_id.
- In the fourth line, we are passing api_key and device_id to Bolt class as constructor arguments and named it as mybolt.
- In the fifth line, we are calling the analogWrite function and passing the GPIO pin number and Value of GPIO.
- In Bolt Python library analogWrite function is used as Pulse Width Modulation for controlling the Intensity of buzzer.
- analogWrite function takes two arguments the first argument is the pin number and the second argument is the Intensity. Intensity can be varied(0 to 255) depending on the need of buzzer sound.
- Now save the file and run the terminal.
sudo python3 buzzer.control.py
- Here, is the video of the Execution:
Comments