buzzerClass docs af
This commit is contained in:
Binary file not shown.
After Width: | Height: | Size: 161 KiB |
Binary file not shown.
After Width: | Height: | Size: 82 KiB |
Binary file not shown.
After Width: | Height: | Size: 788 KiB |
Binary file not shown.
After Width: | Height: | Size: 816 KiB |
@@ -5,7 +5,7 @@ This class is intended to assign an input and output source for a button to acti
|
||||
|
||||
This class code allows the user to easily add new buzzers by simply creating an object and calling the appropriate function.
|
||||
|
||||
##### constructor
|
||||
##### Constructor
|
||||
Inside the class, a constructor is defined. In C++, this constructor shares the same name as the class itself. Every time the class is called, the constructor is activated with the given data.
|
||||
|
||||
##### Class functions
|
||||
@@ -18,10 +18,41 @@ After defining the class, an object needs to be made. This object will immediate
|
||||
|
||||
In this instance, the buzzer pin is set to 12 and the button pin to 20.
|
||||
|
||||
##### using the class
|
||||
##### Using the class
|
||||
In the loop function, the new object is placed along with the function defined in the class to activate it. This function executes with the variable data provided in the constructor. Here, it checks if the specified pin is receiving a signal and then only outputs a signal to the buzzer when there is one.
|
||||
|
||||
##### Link to code
|
||||
(https://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-3/qaajeeqiinii59/-/blob/main/docs/LearningProcessBram/ArduinoExperience/classesArduino/buzzerclasses.ino?ref_type=heads)
|
||||
|
||||
### The board
|
||||
The fysical board should look something like this:
|
||||

|
||||
The board is simple and easy to recreate and has lots of space left for other functions.
|
||||
|
||||
By making this class, the addition of more buzzers is very easy. As long as there are pins, there can be a buzzer.
|
||||
|
||||
For this example, I have only used one, but adding more would be no problem. Just make a object, give the pin numbers and call the function.
|
||||
|
||||
The wireframe for this board would looke something like this:
|
||||

|
||||
|
||||
I tried making it as clear as possible by moving some parts around and clearing some intertwining wires.
|
||||
|
||||
###### My Fysical Recreation.
|
||||
To properly demonstrate this code in action, I recreated the board. In the image, you can see that I plugged in three different LEDs.
|
||||

|
||||
In the image, you can see that I plugged in three different LEDs.
|
||||
This was done to show off that the board/code works, as it's not possible to see if a buzzer is working on camera.
|
||||
|
||||
For the time being, pretend that the LED and resistor combinations are separate buzzers.
|
||||
|
||||
To make this board turn all the buzzers/LEDs on, I needed to create three different objects. These objects looked like this:
|
||||

|
||||
The first variable is where I want the buzzer to connect, and the second variable is where I want the button to be connected.
|
||||
|
||||
After this, I simply placed the objects in the loop and called the function we made in the class:
|
||||

|
||||
|
||||
Now, we simply push the code to The Esp and try it out.
|
||||

|
||||
Now, we have effectively made the LEDs/buzzers turn on with the push of a single button.
|
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
Reference in New Issue
Block a user