This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:iot-open:practical:hardware:sut:esp32:emb8_1 [2024/03/06 18:01] – [FAQ] pczekalski | en:iot-open:practical:hardware:sut:esp32:emb8_1 [2024/04/09 16:03] (current) – [Steps] pczekalski | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== EMB8: Controlling Smart LED stripe ===== | ||
| + | A Smart LED stripe (also referenced as Digital LED or NEOPIXEL) is a chain of connected LEDs, commonly RGB, but other combinations such as RGBWW (Red+Green+Blue+Warm White+Cold White) or WWA (Warm White+Cold White+Amber) exist. They are controlled with just one pin/GPIO. GPIO drives a first LED in a chain and the LED relays configuration to the next one, and so on.\\ The most common type of LED stripes is WS2812B (RGB). Initially LED Stripes were powered with 5V, but that limits the length of the chain up to some 1-2m (because of the voltage drop), so nowadays LED stripes powered with 12V and even 24V are getting more and more popular.\\ \\ | ||
| + | In this scenario you will learn how to control a small LED RGB Stripe, composed of 8 Smart (Digital) LEDs. | ||
| + | |||
| + | ===== Prerequisites ===== | ||
| + | Familiarise yourself with a hardware reference: this LED Stripe is controlled with a single GPIO (GPIO 34), as presented in the "// | ||
| + | <code ini> | ||
| + | lib_deps = freenove/ | ||
| + | </ | ||
| + | <note tip> | ||
| + | |||
| + | There are at least two ways (algorithms) to implement this task: | ||
| + | * using dummy blocking ('' | ||
| + | * using a timer (see advanced scenario below). | ||
| + | |||
| + | ===== Suggested Readings and Knowledge Resources ===== | ||
| + | * [[en: | ||
| + | * [[en: | ||
| + | * [[en: | ||
| + | * [[en: | ||
| + | * [[en: | ||
| + | |||
| + | ===== Hands-on Lab Scenario ===== | ||
| + | |||
| + | ==== Task to be implemented ==== | ||
| + | Implement a rainbow of colours flowing through the LED Stripe. | ||
| + | <note important> | ||
| + | |||
| + | ==== Start ==== | ||
| + | When booking a device, ensure the LED stripe is visible in the camera. | ||
| + | <note important> | ||
| + | <note tip> | ||
| + | |||
| + | ==== Steps ==== | ||
| + | Below, we provide a sample colour configuration that does not reflect the desired effect that should result from the exercise. It is just for instructional purposes. You need to invent how to implement a rainbow effect yourself. | ||
| + | === Step 1 === | ||
| + | Include necessary library: | ||
| + | <code c> | ||
| + | #include " | ||
| + | </ | ||
| + | |||
| + | === Step 2 === | ||
| + | Declare configuration and a controller class: | ||
| + | <code c> | ||
| + | #define WLEDS_COUNT | ||
| + | #define WLEDS_PIN | ||
| + | #define WLEDS_CHANNEL | ||
| + | |||
| + | static Freenove_ESP32_WS2812 stripe = Freenove_ESP32_WS2812(WLEDS_COUNT, | ||
| + | </ | ||
| + | === Step 3 === | ||
| + | To switch a particular LED, use the following function: | ||
| + | <code c> | ||
| + | stripe.setLedColorData(1, | ||
| + | stripe.show(); | ||
| + | </ | ||
| + | Parameters are: '' | ||
| + | <note tip>Note that the index is 0-based, so in the case of our device, valid indexes are 0...7.</ | ||
| + | |||
| + | If you want to set all LEDs in the stripe to the same colour, there is a handy function: '' | ||
| + | |||
| + | ==== Result validation ==== | ||
| + | Observe the flow of the colours via the stripe. | ||
| + | |||
| + | ===== FAQ ===== | ||
| + | **I cannot see the colour via the video camera - everything looks white...**: Try to lower the LED's brightness. | ||
| + | |||
| + | <WRAP noprint> | ||
| + | ===== Project information ===== | ||
| + | {{: | ||
| + | This Intellectual Output was implemented under the Erasmus+ KA2.\\ | ||
| + | Project IOT-OPEN.EU Reloaded – Education-based strengthening of the European universities, | ||
| + | Project number: 2022-1-PL01-KA220-HED-000085090. | ||
| + | |||
| + | **__Erasmus+ Disclaimer__**\\ | ||
| + | This project has been funded with support from the European Commission. \\ | ||
| + | This publication reflects the views of only the author, and the Commission cannot be held responsible for any use that may be made of the information contained therein. | ||
| + | |||
| + | **__Copyright Notice__**\\ | ||
| + | This content was created by the IOT-OPEN.EU Reloaded consortium, 2022, | ||
| + | The content is Copyrighted and distributed under CC BY-NC [[https:// | ||
| + | <figure label> | ||
| + | {{: | ||
| + | </ | ||
| + | </ | ||
| + | |||