The digital output voltage of Arduino is 5V, and the normal working voltage of our RGBLED is about 2~3V.So we need resistors to limit the current.Since different colors of led have different brightness at the same current, we need to give different resistances.
You'll find a few lines of code at the head of the code template that defines the structure of the packet between the microcontroller and the phone.
We have to control 3 leds with pwm, so we define 3 byte variables in the code. Other code is related to the underlying communication, please keep it as it is.
There are already two structure defined in code template as shown above. The txPack and rxPack. You can directly access the variables in the structure by the form like 'var = rxPack.bytes[0]'
There are only three functions to use to implement a complete data transfer.
The first step is to create a project.How to create a project?
Then you need to define the packet structure in communication page.How to configure?
Create three seekbars to control RGB LED. One thing to notice is the range of byte. The range of byte is -128~127 in BTMCU, but we want to get 0~255 in Arduino. The first solution is to narrow the range of seekbar to 0~127 then '*2' in Arduino program. The other solution is to '+128' in Arduino program to get the value in 0-255.
I chose the first way, so I need to modify the value range of the seekbar. How to edit?
Configuration is finished. Scan and connect the bluetooth device.How to connect?
Finally, run the project.How to run?
Hope you can make amazing works.