1 of 83

Circuit Playground Circuit Python

& The Thonny IDE

Jan 12, 2025

STEAM Clown ™ Productions

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

2 of 83

Teachers: Before You Present

  • Update your LMS links and any other local Google links (my will always be open to "Anyone With A Link" so you can still always point to my presentations and links… But if you are localizing this curriculum, you might want to also update any external links. EX: Canvas Announcements, Canvas Links, or Delete the bullets linking to Canvas links (Typically Labs)
  • Circuit Playground Hardware - If students are equipped Chromebooks, the best way to edit code is using an online editor such as this one: https://urfdvw.github.io/CircuitPython-online-IDE/

2

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

3 of 83

Licensing & Attribution

My Open Source Philosophy - I have come to realize that I’m really not competing with other teachers. Maybe I have some local competition, �but in reality, if a student is not coming to my class or my school, then I’m not competing with other teachers in any way… If you work more than a �District away, then we really are not competitors. Let's Share... Collaborate... Help each other... I, and you, may have sweat blood and tears developing a lesson plan, a lab, or presentation… There is an ENORMOUS unpaid value there… I get that… I don’t begrudge teachers who are trying to sell their collateral… I’m just saying that is not what I’m going to do. This is my plan… I’m going to share virtually everything I develop. Join Me!!! See More

CC BY-NC-SA 4.0

https://creativecommons.org/licenses/by-nc-sa/4.0/

https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode

GNU Public License & EUPL (European Union Public Licence)

Any included or linked Programming Code Is licensed under GNU General Public License v3.0 & and / or licensed under EUPL 1.2 or later

See the Appendix for Additional Licensing & Attribution Information

3

Please maintain this slide with any modifications you make:

This content is licensed as Open Source / Creative Commons: A Specific use license has been provided to Entities & Organizations listed in the Appendix

Much of the content in these slides is a Re-Telling of material provided by many open source and creative commons internet resources. There are so many Awesome sites, that are open source sites for teaching STEAM Curriculum. I have modified them some, to work better for my Mechatronics Engineering class. I have even used AI and ChatGPT, and Other open-source technical sites.

Other Contributors: My teacher friends, with additional content.

Dec 15, 2024

See Sourced Sites In The Appendix

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

4 of 83

Sponsorship Page

I would like to thank <Your Company or Organization Here> for their generous support of my classroom and curriculum development. <Your Company or Organization Here> has <Your value proposition, call to action, & related content and message>

How to Provide a Stipend: You can send something to my personal PayPal.Me Account, Venmo Account, or my Patrion Account, even Buy Stuff On My Amazon Classroom Wishlist, donate to my DonorsChoose projects, or contact me at TopClown@STEAMClown.org, if you want to contribute another way.

(If you would like to sponsor this presentation, please contact TopClown@STEAMClown.org )

4

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

5 of 83

Resources & Materials Needed

  • PC, Laptop or Other device to access sites & applications specified by your Instructor
  • Each lesson will have specific items needed to complete the labs and tasks
  • Circuit Playground CPX Adafruit board
  • USB cable Micro
  • Circuit Python installed on CPX

5

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

6 of 83

Objective, Overview, & Introduction

CircuitPython is a streamlined version of Python designed specifically for microcontrollers. It simplifies programming by allowing users to write, edit, and run Python code directly on compatible hardware. CircuitPython is optimized for constrained environments like microcontrollers, focusing on quick prototyping, hardware interaction, and ease of us

6

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

7 of 83

What You Will Know...

Prior Knowledge & Certifications

  • Some knowledge of Microcontrollers, like the Arduino

What You Will Know & Be Able To Do

  • Install CircuitPython on microcontroller and verify proper setup.
  • Write Python scripts to control built-in hardware components such as LEDs, buttons, and sensors.
  • Integrate code using CircuitPython libraries.
  • Debug and troubleshoot errors in their code effectively using serial output and error messages.

7

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

8 of 83

How You Will Be Measured

  • You will show the ability to explain the key lesson concepts
  • Answer a few Quiz questions
  • Demonstrate your understanding of the coding concepts through programming labs

8

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

9 of 83

Essential Questions

  • "Why is CircuitPython a powerful tool for learning how to interact with hardware and sensors?"
  • "How does using CircuitPython prepare us for future careers in engineering, technology, and innovation?"

9

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

10 of 83

Essential Questions

"Why is CircuitPython a powerful tool for learning how to interact with hardware and sensors?"

  • This question encourages students to reflect on how CircuitPython’s simplicity and accessibility make it an effective bridge between coding and physical hardware, opening up possibilities for creating functional, interactive devices.

"How does using CircuitPython prepare us for future careers in engineering, technology, and innovation?"

  • This question prompts students to think about how CircuitPython's real-world applications in IoT, automation, and robotics develop foundational skills needed for advanced STEM careers.

10

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

11 of 83

New Words or Concepts...

  • CircuitPython Runtime
  • Bootloader Mode
  • Code.py
  • Serial Console
  • Adafruit Circuit Python Library Bundle
  • Built-in Sensors

11

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

12 of 83

New Words or Concepts...

  • CircuitPython Runtime - The environment that runs on microcontrollers, enabling Python scripts to execute and manage hardware interactions.
  • Code.py - The default Python script file name that CircuitPython automatically runs when the microcontroller powers on or resets.
  • Adafruit Library Bundle - A collection of precompiled libraries and modules for CircuitPython, designed to support a wide range of hardware components and simplify project development. Individual files containing Python code, either built into CircuitPython or imported from the Adafruit library bundle, that provide additional functionality (e.g., handling hardware like sensors or displays).
  • Serial Console - A tool used for debugging and interacting with a microcontroller, providing real-time feedback and a REPL (Read-Eval-Print Loop) for testing code.
  • Bootloader Mode - A special mode on a microcontroller that allows firmware updates, including installing or updating CircuitPython.
  • Pin Mapping - The configuration of the microcontroller's physical pins, specifying their functions (e.g., digital I/O, analog input, or power).
  • Built-in Sensors - Hardware components integrated into CircuitPython-compatible boards (e.g., accelerometers, temperature sensors) that can be accessed and controlled directly through Python scripts.

12

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

13 of 83

👉 Open A Python IDE:

  • Browser: You can use a web based Browser IDE like:
  • Installed Python IDLE or Thonny: If you installed a Python IDE, open an IDE Editor window

13

print("Hisssssssssss")

Try This 👉

Replit - PythonTutor - Shell

Bookmark This 👉

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

14 of 83

Introduction to Circuit Python on �- Circuit Playground Express (aka CPX)�- Circuit Playground Blue (aka CPB)

14

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

15 of 83

CPB is a Programmable Microcontroller

15

Circuit Playground Blue (CPB) is an excellent platform for students for learn electronics and programming.

Unlike other microcontrollers where you have to purchase additional electronic components, CPB has numerous built-in components that you can incorporate into your code from the day 1.

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

16 of 83

Some Of The Great Goodies Baked In To Each Circuit Playground Bluefruit:

  • 1 x nRF52840 Cortex M4 processor with Bluetooth Low Energy support
  • 10 x mini NeoPixels, each one can display any color
  • 1 x Motion sensor (LIS3DH triple-axis accelerometer with tap detection, free-fall detection)
  • 1 x Temperature sensor (thermistor)
  • 1 x Light sensor (phototransistor). Can also act as a color sensor and pulse sensor.
  • 1 x Sound sensor (MEMS microphone)
  • 1 x Mini speaker with class D amplifier (7.5mm magnetic speaker/buzzer)
  • 2 x Push buttons, labeled A and B
  • 1 x Slide switch
  • 8 x alligator-clip friendly input/output pins
  • Includes I2C, UART, 6 pins that can do analog inputs, multiple PWM outputs
  • Green "ON" LED so you know its powered
  • Red "#13" LED for basic blinking
  • Reset button
  • 2 MB of SPI Flash storage, used primarily with CircuitPython to store code and libraries.
  • MicroUSB port for programming and debugging
  • USB port can act like serial port, keyboard, mouse, joystick or MIDI!

16

Click

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

17 of 83

17

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

18 of 83

Additional Resources

18

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

19 of 83

19

What is CircuitPython?

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

20 of 83

CircuitPython is based on Python

Python is the fastest growing programming language. It's used everywhere. It supports modules and packages which means it's easy to reuse your code for other projects. It has a built in interpreter which means there are no extra steps, like compiling, to get your code to work. And of course, Python is Open Source Software which means it's free for anyone to use, modify or improve upon.

CircuitPython adds hardware (Microcontroller) support to all of these amazing features. If you already have Python knowledge, you can easily apply that to using CircuitPython. If you have no previous experience, it's really simple to get started!

20

How do I connect Hardware Pins?�How do i Blink and LED?�How do I read an UltraSonic Sensor?�How do I turn a Motor or Servo?

Circuit Python has the Libraries and functions to do that.

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

21 of 83

CircuitPython is a programming language designed for programming microcontrollers, which are small, low-cost computers embedded into various devices. It is a variant or subset of the Python programming language adapted to run on microcontrollers and small single-board computers. CircuitPython aims to make it easy for beginners and non-programmers to get started with hardware projects. Here are some key differences between CircuitPython and regular Python:

  • Hardware Interaction: CircuitPython is designed to work seamlessly with hardware components such as sensors, LEDs, motors, and other electronic devices. It includes libraries and modules specifically tailored for interacting with the input and output pins of microcontrollers.
  • Memory and Resource Constraints: Microcontrollers often have limited resources compared to regular computers. CircuitPython is optimized for these resource-constrained environments, and it has a smaller memory footprint compared to a full-fledged Python installation.
  • Ease of Use: CircuitPython is designed to be beginner-friendly and user-friendly. It often comes with built-in libraries and modules that simplify common hardware-related tasks. The goal is to make it accessible for those who may be new to both programming and electronics.
  • Cross-Platform Compatibility: While regular Python is a versatile language that can run on a variety of platforms, CircuitPython is specifically tailored for microcontrollers. It may not be as versatile as regular Python for general-purpose computing tasks but excels in the context of hardware and embedded systems.
  • Development Environment: CircuitPython often integrates with specific development boards and platforms, and it may have its own development environment or tools tailored for working with microcontrollers.

It's important to note that CircuitPython and regular Python are not mutually exclusive. They serve different purposes, and the choice between them depends on the specific requirements of a project. Regular Python is better suited for general-purpose programming on desktops and servers, while CircuitPython is ideal for programming microcontrollers in embedded systems and electronics projects.

21

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

22 of 83

Circuit Python

  • Circuit Python is a subset of Python 3 programming language designed to use Python code on low-cost microcontroller such Circuit Playground Express (CPX) or Circuit Playground Blue (CPB) to control input/output devices.
  • Circuit Python is NOT pre-installed on CPX/CPB so users must install it on CPX and CPB.

22

Download & install

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

23 of 83

Plug CPX/CPB to your Computer

23

ProTip: After you plug the USB cable into your CPX/CPB, Never Unplug It!!!!

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

24 of 83

Check!

  • Check to see if your CPX/CPB is already setup with CircuitPython.
  • Plug in your CPX/CPB to your computer's USB port. Open your File Explorer/Finder to read the name of the CPX/CPB mounted as a USB drive.�

  • If the USB drive name is CIRCUITPY, you're good… Maybe… Check the version of Circuit Python…

24

Reset Button

You may need to press the reset button twice, fast… This should have the Circuit Playground show up as a drive

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

25 of 83

Check - Boot_out.txt

  • Open the boot_out.txt file

25

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

26 of 83

Check - Boot_out.txt

  • Adafruit CircuitPython 8.2.9 on 2023-12-06 or better
  • for 2024-2025, the latest was CircuitPython 9.2.1
  • If the USB drive name is CPLAYBOOT, you must install Circuit Python. Please continue.

26

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

27 of 83

Check

27

Can't See CPLAYBOOT or CIRCUITPY

You may need to press the reset button twice, fast… This should have the Circuit Playground show up as a drive

Press Reset Button fast twice

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

28 of 83

CPLAYBTBOOT

28

You may need to press the reset button twice, fast… This should have the Circuit Playground show up as a drive

Reset Button

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

29 of 83

Download Circuit Python

  • On your browser, go to http://circuitpython.org/downloads
  • if you have a:
    • Circuit Playground Express
    • Circuit Playground Bluefruit

29

Click

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

30 of 83

Download Circuit Python

  • Click on �DOWNLOAD .UF2 NOW
  • Save the UF2 on your desktop for each access.

30

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

31 of 83

Download The Latest Bluefruit .uf2 File

31

Look in Downloads

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

32 of 83

Connect CPX/CPB to Your PC/Mac

  • Use the supplied USB cable to connect your CPX/CPB to your computer.
  • On your CPX/CPB, press the reset button twice. This should turn all LEDs to solid green.

32

  1. Press the reset button twice.

2) Verify that all LEDs are changed to solid green.

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

33 of 83

Flash Your CPX

  • Your computer's File Explorer/Finder will show the new USB drive named CPLAYBOOT.
  • Drag and drop the downloaded UF2 file to this drive.
  • This will automatically reset your CPX/CPB and remount it to your computer

33

  1. Click on the new USB drive called CPLAYBOOT
  • Drag and drop the downloaded UF2 file here.

3) Wait until your CPX reboots

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

34 of 83

Confirm!

  • Your computer's File Explorer/Finder will now show the new USB drive named CIRCUITPY. This means your CPX/CPB is now running Circuit Python.
  • That's it. Your CPX/CPB is now running Circuit Python!

34

New CIRCUITPY USB drive

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

35 of 83

CIRCUITPY - WooHooo

35

Reset Button

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

36 of 83

CIRCUITPY Show Up As A Drive

36

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

37 of 83

code.py is the File to Edit Your Python In

37

code.py

What Are We Going To Edit It With? IDE?

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

38 of 83

38

Circuit Python Online IDE

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

39 of 83

Circuit Python Online IDE

39

Bookmark it!

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

40 of 83

Circuit Python Online IDE

40

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

41 of 83

Circuit Python Online IDE

41

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

42 of 83

Circuit Python Online IDE

42

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

43 of 83

Circuit Python Online IDE

43

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

44 of 83

Your CPX always runs the Python code file called code.py. Let's open it on your editor.

44

Open "code.py"

Your CPX/CPB always runs the Python code file called code.py - Let's open it in your editor.

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

45 of 83

Python Editor

  • Your CPX/CPB always run the Python code file called code.py. Let's open it on your editor.

45

Click on code.py

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

46 of 83

Python Editor

  • Let's change "world" to your name and run it.

46

1. Enter your name here

3. See your new output here

2. Click on > (run) button.

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

47 of 83

Syntax Error

  • Your code must follow the Python syntax rules. For example, the print statement must have your text message in between (" and ").
  • What if you didn't follow the rule?

47

Missing " on the left side

Your IDE will say you have SyntaxError

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

48 of 83

Syntax Error

  • Also, your CPX/CPB LED's will blink RED when it encounters an error.

48

Flashes twice every 5 seconds

Flashing green means your code ended without error

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

49 of 83

Terminal print("Hi") Error

  • Problem: Windows may assign a conflicting COM port.
    • Unable to connect to COM5: could not open port 'COM5': OSError(22, 'The semaphore timeout period has expired.', None, 121)
  • Possible Solution:
    • Open Device Manager (press Win + X and select it).
    • Expand Ports (COM & LPT) and locate the Circuit Playground Bluefruit (likely labeled as USB Serial Device or similar).
    • Right-click the device and select Properties > Port Settings > Advanced.
    • Change the COM port to a number below 10 (e.g., COM3) and click OK.
    • Reconnect the board in Thonny using the new COM port.

49

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

50 of 83

Your First Circuit Python Code

50

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

51 of 83

Blink

# Save on CPX/CPB as code.py

# Blinks the top right RED LED

import board

import digitalio

import time

led = digitalio.DigitalInOut(board.LED)

led.direction = digitalio.Direction.OUTPUT

while True:

led.value = True

time.sleep(0.1)

led.value = False

time.sleep(0.1)

51

Click

Paste it into your "code.py" file

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

52 of 83

Circuit Python Online IDE

52

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

53 of 83

Click to "Save & Run"

53

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

54 of 83

54

Is It Blinking?

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

55 of 83

Control C�Control D

55

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

56 of 83

STOP & RELOAD

56

To reload code.py and run whatever is in there, do CTRL-D

Most likely, you'll be writing code that runs forever (meaning in infinite loop). To stop your code from running forever, you can do CTRL-C

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

57 of 83

LAB #1 Blink

  • Blink Faster / Slower

  • What Pin is the LED Blinking on?
    • led = digitalio.DigitalInOut(board.LED)
    • Can you make it reference the Pin 13 Directly? Rather than the "BuiltIn" value of "LED"
    • How do you reference the I/O Pins?
    • Can you "blink" on the Digital Pin 10?
      • Is it working? How do you know?
    • Can you "blink" on the Analog Pin 3?

57

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

58 of 83

58

lib?

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

59 of 83

You Need Some Libraries…

  • Go and download the latest CPX Library for your device. We are using the Circuit Python 9.x.x, with the UF2, so use the Bundle Version 9.x

59

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

60 of 83

You Don't Need Everything…

Pro Tip: Only load the libraries you are actually using. Why?

Copy the following folders and files from the bundle lib folder to the lib folder on your CIRCUITPY drive:

  • adafruit_ble
  • adafruit_bluefruit_connect
  • adafruit_bus_device
  • adafruit_circuitplayground
  • adafruit_gizmo
  • adafruit_hid
  • adafruit_lis3dh.mpy
  • adafruit_thermistor.mpy
  • neopixel.mpy

60

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

61 of 83

61

Thonny?

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

62 of 83

Thonny!!!!!!!!!!!!!!!!!!!!

https://thonny.org/

We are using the latest �version 4.1.7

62

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

63 of 83

63

1) Click on the Windows Version

2) Installer with 64-bit � Python 4.1.7

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

64 of 83

Let's Setup Thonny To Point To the CPX/CPB and CircuitPython

64

1) Tools → Options

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

65 of 83

Let's Setup Thonny To Point To the CPX/CPB and CircuitPython

65

2) Interpreter

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

66 of 83

Let's Setup Thonny To Point To the CPX/CPB and CircuitPython

66

3) Select The Circuit Python Interpreter

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

67 of 83

Let's Setup Thonny To Point To the CPX/CPB and CircuitPython

67

4) Select The Circuit Python Interpreter

CircuitPython (generic)

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

68 of 83

Let's Setup Thonny To Point To the CPX/CPB and CircuitPython

68

5) Select Port - Try To Detect Automatically Probably will work, but if not select the appropriate USB port

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

69 of 83

Let's Setup Thonny To Point To the CPX/CPB and CircuitPython

69

6) Leave These All checked

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

70 of 83

Let's Edit Your First Circuit Playground Python File

70

1) File → Open or New

2) Select code.py

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

71 of 83

Circuit Playground CPX/CPB - Blink

Simple Blink program that blinks the top right RED LED

71

import board

import digitalio

import time

led = digitalio.DigitalInOut(board.LED)

led.direction = digitalio.Direction.OUTPUT

while True:

led.value = True

time.sleep(0.1)

led.value = False

time.sleep(0.1)

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

72 of 83

Circuit Playground CPX/CPB - Blink

Simple Blink program that blinks the top right RED LED

72

#import time

from time import sleep

from adafruit_circuitplayground import cp

print("Hello <Your Name>")

while True:

cp.red_led = True

sleep(0.5)

cp.red_led = False

sleep(0.5)

Alternate Code, using different Library options

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

73 of 83

LAB #2 Blink

  • Check that you still have your code.py
  • Can you still change the "Blinking"

  • Can you add a print('Hello Python World') to your code?
    • print this just one time
  • Can you add a print() that will print the status of your LED?
    • print this every time your LED turns on/off

73

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

74 of 83

Summary

WooHoo, You have setup and blinked and LED

Dig Deeper:

74

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

75 of 83

Let's Check Your Understanding

75

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

76 of 83

Thank You…

Questions?

76

Jim Burnham (AKA STEAM Clown)

  • Mechatronics Engineering Instructor at Silicon Valley Career Technical Education (SVCTE)
  • Engineering Teacher, Curriculum Developer, Workshop & Conference Presenter
    • Top Clown at TopClown@STEAMClown.org
    • LinkedIn - https://www.linkedin.com/in/jim-burnham-2243018/
    • Line - jim.the.steam.clown
    • Youtube - @jimthesteamclown
    • Google Number - ‪+1 (669) 252-0925‬ <-- TXT - Tell me who you are... "Hi, this is <your name>, and I want to tell you...."
  • Mechatronics Engineering Open-Source Google Site (AKA - Fire Breathing Robots)
  • Want to Support a Teacher? - Here Is How Can You Help

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

77 of 83

Reference Slides

77

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

78 of 83

Links for Students

78

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

79 of 83

Appendix

79

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

80 of 83

Education Standards

California 2013 CTE Standards

  • C3.5 - Engineering and Architecture Pathway
    • Demonstrate the ability to write code for sensors and actuators to perform tasks.
    • Application: Students program sensors and NeoPixels in CircuitPython, learning practical engineering concepts.
  • D2.4 - Information and Communication Technologies Pathway
    • Use programming languages to analyze and solve problems in a variety of disciplines.
    • Application: Students use CircuitPython to develop real-world applications like data logging or automation.
  • D3.3 - Manufacturing and Product Development Pathway
    • Evaluate and refine prototypes to meet functional requirements.
    • Application: Students troubleshoot and optimize CircuitPython-based hardware prototypes.

Next Generation Science Standards (NGSS)

  • HS-ETS1-3: Engineering Design
    • Evaluate a solution to a complex real-world problem based on prioritized criteria and trade-offs.
    • Application: Students create and refine CircuitPython projects such as environmental monitors or interactive devices.
  • MS-PS4-3: Waves and Applications in Technologies
    • Apply scientific principles to design a device that converts one form of energy into another.
    • Application: Students use CircuitPython to program motion sensors or LEDs, converting data into visual feedback.
  • HS-PS3-5: Energy and Systems
    • Develop and use models of energy transfer within systems.
    • Application: Students design projects where hardware components powered by CircuitPython demonstrate energy transformations, like lighting an LED based on sensor data.

80

80

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

81 of 83

Appendix : Primary Sources & Attribution for Material Used

81

Please maintain this slide with any modifications you make

  • <If you modify these slides, Add Your Logo and Attribution here>

Additional Attribution & Sources:

STEAM Clown - License & Attribution Creative Commons License CC-BY-NC-SA 4.0 - Much of this interpretation is primarily the Intellectual Property of Jim Burnham, TopClown, at STEAMClown.org, I may have used other sources, and in that Re-Telling, I have made my best attempt to properly attribute, or reference any of these sources or works. They are probably listed below. I’m a Super Huge proponent of Open Source - Find out more...

Please maintain this slide with any modifications you make:

This content is licensed as Open Source / Creative Commons: A Specific use license has been provided to the Silicon Valley education Foundation & Silicon Valley CTE

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

82 of 83

Image Reference & Sources

82

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions

83 of 83

What To Fix, Add, Or Change

Presentation Planning:

  • add /make a separate thonny presentation for local python

83

© Copyright - STEAM Clown TM

Creative Commons Licenses - BY-NC-SA 4.0

STEAM Clown TM Productions