You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/arduino-cloud/01.guides/04.micropython/content.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -222,13 +222,13 @@ To use variables in Arduino IoT Cloud that are not of a basic type, you can set
222
222
223
223
On the programming side, you need to import the corresponding class in MicroPython. For the colored light example, you need to import the `ColoredLight` class:
224
224
225
-
```py
225
+
```python
226
226
from arduino_iot_cloud import ColoredLight
227
227
```
228
228
229
229
The cloud variable needs then to be registered with the client using that type and the name that you gave it ("light" in our example):
@@ -241,15 +241,15 @@ In the callback function for this variable ("on_colored_light_changed") you will
241
241
242
242
Once you receive these values from the Cloud you will need to convert them to RGB so you can set the RGB LEDs accordingly. For reasons of brevity we won't go into the code for the color conversion, it is provided however in the full example code further down. Also we need to make all three RGB LEDs available in the code so their value can be set:
243
243
244
-
```py
244
+
```python
245
245
led_red = Pin("LEDR", Pin.OUT)
246
246
led_green = Pin("LEDG", Pin.OUT)
247
247
led_blue = Pin("LEDB", Pin.OUT)
248
248
```
249
249
250
250
Then each of the three LEDs' brightness needs to be set so that the resulting color is as desired. This is done using a technique called [PWM](/learn/microcontrollers/analog-output/):
251
251
252
-
```py
252
+
```python
253
253
defset_led_brightness(led, brightness):
254
254
"""
255
255
Sets the brightness (0 - 255) of an LED using PWM.
0 commit comments