Skip to content

Commit

Permalink
Merge pull request #25 from jposada202020/master
Browse files Browse the repository at this point in the history
Adding Raspberry Pi Pico to the Jupyter Notebook
  • Loading branch information
brentru committed Feb 17, 2021
2 parents 7c053d3 + 1e53010 commit 9c563e5
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 4 deletions.
9 changes: 7 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ running `CircuitPython <https://github.com/adafruit/circuitpython>`_ from within
Status
------

This project's status is experimental. It has been tested with CircuitPython (SAMD) boards and the
Feather HUZZAH (ESP8266) with CircuitPython 3.x.
This project's status is experimental. It has been tested with CircuitPython 3.x in (SAMD) boards and
Feather HUZZAH (ESP8266).
With CircuitPython 6.x in Raspberry Pi Pico

It may break, and if it does, please file an
`issue on this repository <https://circuitpython-kernel.readthedocs.io/en/latest/contributing.html>`__.
Expand Down Expand Up @@ -55,6 +56,10 @@ Other Adafruit Boards

- `Adafruit Feather HUZZAH ESP8266 <https://www.adafruit.com/products/2821>`__

Other Boards
~~~~~~~~~~~~~~~~~~~~~
- `Raspberry Pi Pico <https://www.adafruit.com/products/4864>`__


Download
--------
Expand Down
3 changes: 2 additions & 1 deletion circuitpython_kernel/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# Vendor IDs
ADAFRUIT_VID = 0x239A # SAMD
ESP8266_VID = 0x10C4 # Huzzah ESP8266
PICO_VID = 0x239A # PICO PI

# repl commands
CHAR_CTRL_A = b'\x01'
Expand Down Expand Up @@ -144,7 +145,7 @@ def _find_board(self):
for port in comports():
# print out each device
BOARD_LOGGER.debug(port.device)
if port.vid == ADAFRUIT_VID or port.vid == ESP8266_VID:
if port.vid == ADAFRUIT_VID or port.vid == ESP8266_VID or port.vid == PICO_VID:
BOARD_LOGGER.debug(f"CircuitPython Board Found at: {port.device}")
BOARD_LOGGER.debug(f"Connected? {self.connected}")
return port.device
Expand Down
4 changes: 3 additions & 1 deletion docs/boardprep.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Before you start using the CircuitPython_Kernel, you'll need a board running CircuitPython. If you're not sure if
the board plugged into your computer is running CircuitPython, check your file explorer for a drive named `CIRCUITPY`

## Designed for CircuitPython (SAMD21 and SAMD51)
## Designed for CircuitPython (SAMD21, SAMD51 and RP2040)

### Boards Supported:

Expand All @@ -18,6 +18,8 @@ the board plugged into your computer is running CircuitPython, check your file e
- [Metro M4 ]( https://www.adafruit.com/product/3382)
- [ItsyBitsy M4](https://www.adafruit.com/product/3727)

- [Raspberry Pi Pico RP2040](https://www.adafruit.com/product/4864)


### Installing CircuitPython Firmware

Expand Down
139 changes: 139 additions & 0 deletions examples/CPX_Blink_Pico.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Blinking a LED\n",
"We're going to be blinking the LED on your Raspberry Pi Pico, right from this Jupyter Notebook!\n",
"\n",
"![cpx led](https://cdn-learn.adafruit.com/assets/assets/000/098/848/large1024/raspberry_pi_circuitpython_RP_01_top_ORIG_2021_01b.jpg?1611338794)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's first check if Jupyter can read our CircuitPython board by running:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"print(os.uname())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First, import `board` and `digitalio` "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import digitalio\n",
"import board"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Create a `digitalio.DigitalInOut` object for the LED in the Raspberry Pi Pico:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cpx_led = digitalio.DigitalInOut(board.LED)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's change the direction of `digitialio.Direction` to be an `OUTPUT`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cpx_led.direction = digitalio.Direction.OUTPUT"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, let's turn it on by changing the value of the pin to `True` "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cpx_led.value = True"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Don't want the LED on? Turn it off by switching the value from `True` to `False`"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"cpx_led.value = False"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "CircuitPython",
"language": "python",
"name": "circuitpython"
},
"language_info": {
"codemirror_mode": {
"name": "python",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"pygments_lexer": "python3",
"version": "3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 9c563e5

Please sign in to comment.