Line: 1 to 1 | ||||||||
---|---|---|---|---|---|---|---|---|
Added: | ||||||||
> > |
Lecture 2: LEDs and NeoPixel CSC 321: Embedded SysytemFirst Semeter 2020/2021 | |||||||
Added: | ||||||||
> > | The ESP32-WROVER-B MCUCPU PinoutPlease note: The pin numbers IOxx on the ESP32 correspond to the GPIO pin numbers Datasheet: https:// www.espressif.com /sites/default/files/documentation/esp32-wrover-b_datasheet_en.pdfMeaning of pins on ESP32How to program the processor
Flashing the codeesptool
How to write a Micropython program?First we need a Micropython interpreter! You find the sources here: https://github.com/micropython/micropython/ In the repository you find ports for the ESP8266 and the ESP32. In order to compile the code you need the ESP-IDF and its cross compilers The code compiles into a binary file (firmware-combined.bin) which contains a boot loader and the interpreter. This binary must be uploaded and flashed. For documentation of the ESP32port of Micropython look at http://docs.micropython.org/en/latest/esp32/tutorial/intro.htmlHow to communicate with the Micropython interpreter?We use a serial connection passing through the micro USB connection. As soon as we connect the processor card to the PC we see the serial port to connect for communicationWhat is REPL?The communication tools: minicomYou see the command prompt and you can interact with Micropython. But … how to upload scripts?The command line tool ampyIDE for Micropython: uPyCraftThonnyThonnyThonny is a complete Integrate Development Environment (IDE) which lets you
ThonnyThonny is an IDE for Python which has provisions for Micropython.Under Tools → Options button you can select the type of Python interpreter you intend to use. Flashing MicropythonCompiling a new version of Micropython is substantially much easier with Thonny. You still need to install esptool first. You just select your port and firmware then install.IoT Hello World programA “Hello World” program, just printing “Hello World” on the screen does not look very exciting. However, this is generally used to verify that the infrastructureCompiler, linker, downloader, flash program are working correctly In embedded systems printing can be quite complex and a blinking LED is used instead. Switching on and off a LEDThe ESP32-WROVER-B have a “user LED” connected to GPIO 19. How do we control this LED?
Micropython hardware functionsThe machine.Pin classSwitch the LED on, version 1Switch the LED on, version 2The blinking LEDNow we put the code into a script and run itChanging the light intensityThe LED is connected to a digital line which can only be set to 0 or Vcc. How can we change the light intensity and dim the LED? The light intensity depends on the average current flowing through the LED. The answer is PWM: pulse width modulation.PWM in MicropythonOur PWM implementationThe WS2812B LEDA more complex LED:
WS2812B timingFor all the details on the ws2812b look athttps://cdn-shop.adafruit.com/datasheets/WS2812B.pdf 24 bit of colour data puts 2e24 colours at your disposal Coding of a single bit The control word: Cascading the WS2812BUsing the neopixel library… and our codeWe have a single neopixel connected to GPIO pin 4 (ESP8266) or GPIO pin 21 (ESP32) This code works on both CPUs!%SLIDESHOWEND% -- Isaac Armah-Mensah - 2021-02-28Comments | |||||||
| ||||||||
Line: 13 to 271 | ||||||||
| ||||||||
Added: | ||||||||
> > |
|