Write scripts to control an RGB LED and read data from an AS7341 color sensor.
Update blink.py
to control a single RGB LED and read.py
to read sensor data from the AS7341. Each script is worth five points. A number of dummy modules are installed by default (via pip install -e .
) to allow you to run tests without the microcontroller. This makes it easy to test on Codespaces and this is also where the autograding will be carried out. Periodically, you can copy the contents from your Pico W back to Codespaces run the pytest
command.
Steps:
- Ensure that MicroPython is installed on your Pico W
- In Codespaces, download the
lib/
folder,blink.py
, andread.py
by right-clicking and selecting "Download". Then, in Thonny, copylib
,blink.py
, andread.py
to your microcontroller. Watch the video below for a demonstration.
- Ensure that your Pico W is inserted correctly into the Maker Pi Pico base
- Ensure that your AS7341 is connected to Grove Port #6
- Edit the two scripts to meet the specifications in the sections below
- Run the scripts directly in Thonny by opening the script and clicking the play button
Follow the directions on blink.py
. You will use the RGB LED housed on the Maker Pi Pico base, which is connected to Pin #28 on the Pico W microcontroller. Turn the LEDs on to a color of your choice, sleep for 2 seconds, and then turn off the LEDs.
Update read.py
so that it returns a dictionary that maps the name to the value for each of the channel wavelengths. Use the Sensor
class from the as7341_sensor.py
module to read the data.
pytest