Tags:
view all tags
---+ !LEDs and !NeoPixel ---++ Introduction The ESP32 has 2 !LEDs on board. The first one indicates power while the second one is user programmable. The user programmable built-in !LED is connected to !GPIO pin 2. <img alt="esp32.png" height="313" src="%ATTACHURL%/esp32.png" title="esp32.png" width="410" /> You can see the !LEDs in the far left, bottom corner. The power !LED is marked "ON" while the user programmable one is marked "L". The !NeoPixel is based on the WS2812 addressable !RGB !LED which is often used in !LED chains. In our case we have 6 !LEDs arranged in a ring with a 7th one placed in the center of the ring. <img alt="leds.png" height="440" src="%ATTACHURL%/leds.png" title="leds.png" width="444" /> Again the !LEDs are accessible, this time through a dedicate serial protocol, on a !GPIO line. For the board we are using the !GPIO line can be selected with solder jumpers. ---++ Further introductory remarks: In comparison with the first exercise session these exercises are rather simple. This is mainly due to the fact that all difficulties in accessing the devices is hidden from you in the drivers which are part of !MicroPython. If you want to know what is going on behind the scene please have a look at https://www.parallax.com/sites/default/files/downloads/28085-WS2812B-RGB-LED-Datasheet.pdf ---++ Exercise 1: Switching the user !LED with !REPL It is actually very easy to access the !LED because all you need is already available in !MicroPython. Just look it up at <br /> [[https://docs.micropython.org/en/latest/esp32/quickref.html#pins-and-gpio][https://docs.micropython.org/en/latest/esp32/quickref.html#pins-and-gpio ]]and try the example using !GPIO pin 2. Don't write a script just yet but switch the !LED on and off with REPL. ---++ Exercise 2: The Embedded System's Hello World Program: The blinking !LED Write a script that makes the !LED blink at 1 Hz (500ms on, 500 ms off). Improve the program by capturing Ctrl-C, which stops the endless loop, switching off the !LED before exiting the program. This can easily be done in a _try..except_ clause capturing the<i> !KeyboardInterrupt</i> exception. ---++ Exercise 3: SOS Probably the most well known Morse sequence is SOS (Save Our Souls) which consists of 3 long sounds (Morse "S") followed by 3 short ones (Morse "O") again followed by 3 long ones. Make the !LED blink the SOS sequence. Pause for 1 s between 2 SOS sequences. ---++ Exercise 4: Change the !LED light intensity The light intensity on the LED can be changed if we do not supply a fixed signal level to it but a frequency. The duty cycle of the signal determines the light intensity. Write a program that increases the intensity in a linear fashion and the decreases it again linearly. -- %USERSIG{UliRaich - 2020-05-05}% ---++ Comments %COMMENT%
Attachments
Attachments
Topic attachments
I
Attachment
History
Action
Size
Date
Who
Comment
png
esp32.png
r1
manage
225.8 K
2020-05-05 - 18:42
UliRaich
png
leds.png
r1
manage
292.6 K
2020-05-05 - 18:40
UliRaich
Edit
|
Attach
|
Watch
|
P
rint version
|
H
istory
:
r8
|
r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Raw edit
|
More topic actions...
Topic revision: r2 - 2020-05-06
-
UliRaich
Home
Site map
AFNOG web
Embedded_Systems web
IoT_Course_English web
IoT_Course_French web
Main web
Sandbox web
TWiki web
IoT_Course_English Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
Edit
Attach
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback