How to code the Vibration module-1?
Hello and welcome to the guide in which we’ll demonstrate how to code the vibration module.
To begin, connect the module to the Batcontroller and connect the Batcontroller to the PC.
Turn the Batcontroller on, and go to code.circuitmess.com.
Create a new sketch and name it “Fire and Vibration”.
In this code, we’ll explore both the vibration motor and the LEDs on the module.
Create this variables block and drag it to the drawing area.
The variable “i” represents the index of the LED that will be turned on. The first LED on the vibration module corresponds to index 0, and the last one is index 14.
Firstly, set the index variable to 0.
Next, add the “Loop forever" block below it.
This block ensures that the code inside it is continuously executed.
Now, look for this block in the Modules block section and set the value of “i” to 0. This will turn off the LED from the previous loop or set its intensity to 0.
With this mathematical operation, we increase “i” by 1. So, with each new loop, “i” increases by 1 and is divided by 15.
This will result in the LEDs turning on and off sequentially.
After this step, set the intensity of the next LED to 60.
In the Modules block section, you can find the block to turn vibration on and off. Remember to include the “sleep 100 ms” block between them.
Finally, add the “sleep 500 ms” block to introduce a delay before the loop restarts.
Run the code and check it out.