diff --git a/.vscode/settings.json b/.vscode/settings.json index ecde0396a..95f34eef8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,57 @@ { "editor.fontSize": 10, "cSpell.words": [ +<<<<<<< HEAD +<<<<<<< HEAD "Adafruit", + "Ampy", + "Barchart", + "Creary", + "Cytron", + "Datasheet", + "Dupont", + "Framebuffers", + "ISRs", + "LEDs", + "Microcenter", + "Microcontroller", + "Micropython", + "Neopixel", + "OLEDs", + "Phillps", + "Photosensor", + "Stackable", + "Thonny", + "UART", + "VBUS", + "baudrate", + "codehilite", + "coderdojo", + "debouncing", + "debuggings", + "hline", + "kiloohms", + "linenums", + "megaohms", + "microsite", + "milliamps", + "mosi", + "numpy", + "oled", + "outliner", + "photoresistor", + "pico", + "saleae", + "solderless", + "thonney", + "transformative", + "utime", + "vals", + "vline" +======= +======= + "Adafruit", +>>>>>>> af6fd1582dc5f2125614460b5b9ee404db3c02df "AGND", "allowfullscreen", "Autoshutdown", @@ -35,11 +85,20 @@ "utime", "VBUS", "VREF", +<<<<<<< HEAD + "VSYS" +>>>>>>> 0b6e3f501f3a042f5782a2d74206aa085657872c +======= "VSYS", +<<<<<<< HEAD + "waveshare" +>>>>>>> d971679f78e0ee95dd3ed75e2093e8a733d65f3f +======= "waveshare", "WLAN" ], "markdown.experimental.validate.ignoreLinks": [ "../img/pi-w.png" +>>>>>>> af6fd1582dc5f2125614460b5b9ee404db3c02df ] } \ No newline at end of file diff --git a/docs/advanced-labs/12-machine-learning.md b/docs/advanced-labs/12-machine-learning.md new file mode 100644 index 000000000..767d3be67 --- /dev/null +++ b/docs/advanced-labs/12-machine-learning.md @@ -0,0 +1,20 @@ +# Machine Learning on the Raspberry Pi RP2040 + +*The RP2040 is ready for machine learning. Are You?* + +James Adams +COO and Director of Hardware +Raspberry Pi Foundation + +Python is the primary language used in machine learning. The TensorFlow Lite (TFLite) machine learning library has already been ported to the RP2040 chip. + +Utronics has created a machine learning development board with a small QVGA monochrome Camera Module has already been built-in to a RP2040 development board. + +We have already seen applications that can use low-resolution cameras to detect faces. + + + +## References + +1. [Uctronics Arducam Pico4ML TinyML Dev Kit: RP2040 Board w/ QVGA Camera, LCD Screen, Onboard Audio, Reset Button & More](https://www.uctronics.com/raspberry-pi-pico/-rp2040-based-arducam-pico4ml-dev-board-for-machine-vision.html) +1. [An RP2040 Based TinyML Dev Board](https://www.arducam.com/pico4ml-an-rp2040-based-platform-for-tiny-machine-learning/) diff --git a/docs/basics/05-neopixel.md b/docs/basics/05-neopixel.md index c47a8671c..e35ff95d9 100644 --- a/docs/basics/05-neopixel.md +++ b/docs/basics/05-neopixel.md @@ -2,13 +2,13 @@ ![NeoPixel Demo](../img/neopixel-demo.gif) -NeoPixels are Red-Green-Blue LEDs that are designed to makes them easy to control with three wires: GND, +5V and a single serial data line. They are very popular with our students because they are powerful, easy to program and full of **bling**. +NeoPixels are Red-Green-Blue LEDs that are designed to make them easy to control with three wires: GND, +5V and a single serial data line. They are popular with our students because they are powerful, easy to program, and full of **bling**. !!! Note - As of March of 2022 there is now built-in support for NeoPixels in the MicroPython 1.18 runtime for the Raspberry Pi RP2040 microcontroller. Although you can still use custom libraries, this tutorial assumes you are using - version 1.18 or later. + As of March of 2022 there is now built-in support for NeoPixels in the MicroPython 1.18 runtime for the Raspberry Pi RP2040 microcontroller. + Although you can still use custom libraries, this tutorial assumes you are using version 1.18 or later of the MicroPython runtime library. -Controlling NeoPixels is challenging since the timing of data being sent must be very precise. Python alone is not fast enough to send bits out of a serial port. So a small function that uses assembly code is used. This code can be called directly from a neopixel driver file so that the user's don't need to see this code. +Controlling NeoPixels is challenging since the timing of data being sent must be very precise. Python alone is not fast enough to send bits out of a serial port. So a small function that uses fast assembly language code is used. This code can be called directly from a neopixel driver file so that the user's don't need to see this code. [MicroPython Example Code on ESP8266](https://docs.micropython.org/en/latest/esp8266/tutorial/neopixel.html) @@ -279,4 +279,4 @@ while True: * [MicroPython RP2 Reference for NeoPixel Driver](https://docs.micropython.org/en/latest/rp2/quickref.html#neopixel-and-apa106-driver) * [Core Electronics: How to use WS2812B RGB LEDs with Raspberry Pi Pico](https://core-electronics.com.au/tutorials/how-to-use-ws2812b-rgb-leds-with-raspberry-pi-pico.html) - HTML page, sample code and video * [MicroPython Library for NeoPixel (used before version 1.18 of the MicroPython RP2 Runtime)](https://docs.micropython.org/en/latest/library/neopixel.html) - note the lack of support for the RP2040 microcontroller. -* [rp2 port no module named array](https://github.com/micropython/micropython/issues/6837) \ No newline at end of file +* [rp2 port no module named array](https://github.com/micropython/micropython/issues/6837) diff --git a/docs/debugging/sample-error.md b/docs/debugging/sample-error.md new file mode 100644 index 000000000..ba84073ef --- /dev/null +++ b/docs/debugging/sample-error.md @@ -0,0 +1,8 @@ +# Sample Error Supression + +```py +try: + micropython.schedule(self.call_handlers, Rotary.ROT_CW) +except RuntimeError: + pass # ignore the error +``` \ No newline at end of file diff --git a/docs/displays/graph/16-images.md b/docs/displays/graph/16-images.md new file mode 100644 index 000000000..d5cb88607 --- /dev/null +++ b/docs/displays/graph/16-images.md @@ -0,0 +1,51 @@ +# Displaying Images on your OLED + +We will use the ```framebuffer``` function to load a binary image into the OLED. + +```python +buffer = bytearray(b"\x00\x00\x00\x00... + +# Load the raspberry pi logo into the framebuffer (the image is 32x32) +fb = framebuf.FrameBuffer(buffer, 32, 32, framebuf.MONO_HLSB) + +oled.fill(0) +oled.blit(fb, 50, 20) # copy the framebuffer to x=50 and y=20 +oled.show() +``` + +## Drawing the Raspberry Pi Logo: + +```py +from machine import Pin, I2C +from ssd1306 import SSD1306_I2C +import framebuf +import utime + +WIDTH = 128 +HEIGHT = 64 + +i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=200000) +print("I2C Address: "+hex(i2c.scan()[0]).upper()) # Display device address +oled = SSD1306_I2C(WIDTH, HEIGHT, i2c) # Init oled display + +# Raspberry Pi logo as 32x32 bytearray +buffer = bytearray(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00|?\x00\x01\x86@\x80\x01\x01\x80\x80\x01\x11\x88\x80\x01\x05\xa0\x80\x00\x83\xc1\x00\x00C\xe3\x00\x00~\xfc\x00\x00L'\x00\x00\x9c\x11\x00\x00\xbf\xfd\x00\x00\xe1\x87\x00\x01\xc1\x83\x80\x02A\x82@\x02A\x82@\x02\xc1\xc2@\x02\xf6>\xc0\x01\xfc=\x80\x01\x18\x18\x80\x01\x88\x10\x80\x00\x8c!\x00\x00\x87\xf1\x00\x00\x7f\xf6\x00\x008\x1c\x00\x00\x0c \x00\x00\x03\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") + +# Load the raspberry pi logo into the framebuffer (the image is 32x32) +fb = framebuf.FrameBuffer(buffer, 32, 32, framebuf.MONO_HLSB) + +oled.fill(0) +# Blit the image from the framebuffer to the oled display +oled.blit(fb, 50, 20) +oled.show() +``` + +But how do we convert a logo into a bytearray? +``` + +## References + +1. [Cytron Example](https://github.com/CytronTechnologies/MAKER-PI-RP2040/blob/main/Examples/MicroPython/OLED/oled_ssd1306.py) +2. [Image to C ByteArray](http://javl.github.io/image2cpp/) +2. [Image to OLED Converter](http://www.majer.ch/lcd/adf_bitmap.php) + diff --git a/docs/img/microswitch-on-alibaba.png b/docs/img/microswitch-on-alibaba.png new file mode 100644 index 000000000..6ed27c788 Binary files /dev/null and b/docs/img/microswitch-on-alibaba.png differ diff --git a/docs/img/pico-pot-diagram.png b/docs/img/pico-pot-diagram.png new file mode 100644 index 000000000..6b01381ae Binary files /dev/null and b/docs/img/pico-pot-diagram.png differ diff --git a/docs/kits/maker-pi-rp2040-robot/02-assembly.md b/docs/kits/maker-pi-rp2040-robot/02-assembly.md index 271218d80..0987ea210 100644 --- a/docs/kits/maker-pi-rp2040-robot/02-assembly.md +++ b/docs/kits/maker-pi-rp2040-robot/02-assembly.md @@ -8,16 +8,22 @@ This kit is a $25 robot kit that we will use in our CoderDojo robotics classes. 3. Screws and nuts 4. 4 AA battery pack 5. Power switch -2. Cytron Maker Pi RP2040 kit +2. Cytron Maker Pi RP2040 Kit 1. Maker Pi RP2040 board 2. 4x Grove to female header cables 3. Screwdriver 4. Silicone rubber feet (pack of 4) -3. Ultrasonce sensor + 5. 4 M2 10mm screws and nuts (for mounting the board to the chassis) +3. Ultrasonic Sensor 1. mounting braket 2. 2 M2 6mm screws and nuts -You will need to provide 4 AA batteries and a Micro USB connector that works with your PC or Mac. +4. You will need to provide 4 AA batteries and a Micro USB connector that works with your PC or Mac. + +6. You will need a drill and 1/8th inch drill bit to put holes on additional mounting spots. + +8. You should have a hot-glue gun available as well. + ## Assemble the SmartCar Chassis @@ -96,7 +102,7 @@ Connect the Maker Pi RP2040 board to the top with the USB connector facing the r ![Maker Pi RP2040 Motor Connections](../img/maker-pi-rp2040-motor-connections.jpg) -Here is a short video of the assembly of a SmartCar Chassis. Note that this video puts the battery on the top, where we put it on the bottom. +Here is a short video of the assembly of a SmartCar Chassis. **Note that this video puts the battery on the top, where we put it on the bottom.** diff --git a/docs/kits/maker-pi-rp2040-robot/06-up-down-motor-lab.md b/docs/kits/maker-pi-rp2040-robot/06-up-down-motor-lab.md index a9efd8d34..aa9182c64 100644 --- a/docs/kits/maker-pi-rp2040-robot/06-up-down-motor-lab.md +++ b/docs/kits/maker-pi-rp2040-robot/06-up-down-motor-lab.md @@ -2,7 +2,7 @@ In this lab, we will make the motor speed change as the mode changes. - + ```py # Motor Setup diff --git a/docs/kits/maker-pi-rp2040-robot/11-ping-lab.md b/docs/kits/maker-pi-rp2040-robot/11-ping-lab.md index c313694f8..e966db77d 100644 --- a/docs/kits/maker-pi-rp2040-robot/11-ping-lab.md +++ b/docs/kits/maker-pi-rp2040-robot/11-ping-lab.md @@ -10,10 +10,10 @@ All wired up ![Maker Pi RP2040 with sensor](../../img/Maker_Pi_RP2040-Ping.jpg) -``` -# Sample code to test HC-SR04 Ultrasonice Ping Sensor +```py +# Sample code to test HC-SR04 Ultrasonic Ping Sensor # Connect GND to any GND pin on the Pico -# Connnect VCC to VBUS or 5 Volt power +# Connect VCC to VBUS or 5 Volt power from machine import Pin, Timer import utime @@ -47,7 +47,7 @@ while True: More advanced version with sound -``` +```py # Sample code to test HC-SR04 Ultrasonice Ping Sensor # Connect GND to any GND pin on the Pico # Connnect VCC to VBUS or 5 Volt power diff --git a/docs/kits/maker-pi-rp2040-robot/23-microswitch-bot.md b/docs/kits/maker-pi-rp2040-robot/23-microswitch-bot.md index 8965490b0..7594dd070 100644 --- a/docs/kits/maker-pi-rp2040-robot/23-microswitch-bot.md +++ b/docs/kits/maker-pi-rp2040-robot/23-microswitch-bot.md @@ -34,7 +34,7 @@ led0 = Pin(0, Pin.OUT) led1 = Pin(1, Pin.OUT) led2 = Pin(2, Pin.OUT) -# input on the lower left of the Pico using a built-in pull-down resistor to keep the value from floating +# MicroSwitch inputs on the Grove connector using a built-in pull-down resistor to keep the value from floating. The other end of the switches go to the 3.3volt connectors of the Grove connectors. middle_switch = Pin(7, Pin.IN, Pin.PULL_DOWN) right_switch = Pin(28, Pin.IN, Pin.PULL_DOWN) left_switch = Pin(27, Pin.IN, Pin.PULL_DOWN) diff --git a/docs/kits/maker-pi-rp2040/03-neopixel-lab.md b/docs/kits/maker-pi-rp2040/03-neopixel-lab.md index e280d6f94..16894ddab 100644 --- a/docs/kits/maker-pi-rp2040/03-neopixel-lab.md +++ b/docs/kits/maker-pi-rp2040/03-neopixel-lab.md @@ -2,6 +2,9 @@ The Maker Pi RP2040 comes with two built-in NeoPixels. Each NeoPixel has a red, green and blue LED inside it. Each of these LEDs can be set to any one of 256 values from 0 (off) to 255 (brightest value). +!!! Note + This lab uses the old syntax for NeoPixels. The new format (using the MicroPython runtime 1.18 or later) is covered in the other NeoPixel labs in this book here: [https://www.coderdojotc.org/micropython/basics/05-neopixel/](https://www.coderdojotc.org/micropython/basics/05-neopixel/) +