May 2020
Intermediate to advanced
262 pages
6h 48m
English
It only takes 12 lines of code to read and display a QR code on screen using MicroPython. The only two libraries we need to import are sensor and image:
import sensorimport image
The sensor library is used by cameras for taking pictures. We store the resulting object in our code as an image object. Hence, we are required to import the image library.
After importing this library, we reset the sensor and then set parameters used for the rest of our code:
sensor.reset()sensor.set_pixformat(sensor.GRAYSCALE)sensor.set_framesize(sensor.QVGA)sensor.set_vflip(1)
Setting the format to GRAYSCALE as opposed to a color format reduces processing needs. Since QR codes are made with a black and white pattern, a color format would be ...