Change the color of the full-color LED with a radio button
Contents
Make things
You can change the color of the full color LED connected to the obniz with the radio button.
Materials
- Full Color LED
 - resistance x3
 - obniz Board
 - Mobile batteries, etc.
 - Smart Phone or PC
 
How to make
Hardware connection
Connect the LED to the obniz Board as shown in the figure, referring to the full color LED parts library.
| obniz | LED | 
|---|---|
| 0 | Green | 
| 1 | Blue | 
| 2 | Red | 
| 3 | Anode or cathode | 
※Please note that the order of the pins may differ depending on the full color LED.
Software
Line 10 let led = obniz.wired(‘FullColorLED’, {r:2, g:0, b:1, common:3, commonType:’cathode_common’}); In the commonType field of let led = obniz.wired(‘FullColorLED’, {r:2, g:0, b:1, common:3, commonType:’cathode_common’}); Depending on the type of LED you have, write anode_common or cathode_common.
Make a radio button as follows.
The name attribute value can only be selected as one of the colors, and the value attribute value has a color for each.
<input type="radio" name="colors" value="red" >red
Get the value attribute value of the button that is being checked with jQuery.
let checkedVal = $('input[name="colors"]:checked').val();
Program
Execute
Select a color and press CHANGE!!! to change the full color LED to the selected color. If you select gradation change, the color will continue to change in a gradient.
		