Short link to this page: bit.ly/db-tas-17
Go to the latest lesson.

Title graphic showing electronics

In this class, for beginning and experienced programmers and “digital makers”, you’ll create several fun projects combining coding with wiring up buttons, sensors and motors, while strengthening your programming skills, and being exposed to the big ideas of computer science.

Resources

Free Learning Time Activities

  • MakeCode
  • p5.js
  • TinkerCad Circuits
  • Create a game with micro:bit or Circuit Playground Express
  • Python practice
  • Scratch or Snap!
  • Beauty and Joy of Computing for Middle School
  • Create something with gates and Hot Wheels track
  • Design something with Illustrator, cut with the laser cutter, and assemble
  • Create something and 3D print it

Hardware

We’ll work with several tiny computers and microcontrollers.

The Raspberry Pi is a full-featured, but small, computer.

The Circuit Playground Express is less powerful than the Raspberry Pi, but includes many sensors and lights, and consumes less power.

Circuit Playground Express photo

The Arduino is a very popular microcontroller, with a large community creating software for it.

Software

  • Python is one of the most popular programming languages, and it’s suitable for beginning programmers as well as professionals.
  • JavaScript/TypeScript is another of the most popular programming languages.
  • C++ is used for programming Arduinos.
  • MakeCode for Circuit Playground Express makes it easy to program the CPX using blocks.
  • Tinkercad Circuits lets you try out your electronics circuits in a simulator before assembling them with real components.

Projects

The best projects might be the ones students come up with themselves, but here are some ideas:

Multiplayer Reaction/Memory Lights Game

Inspired by Simon game

Code walkthrough video

Features:

  • Raspberry Pi tiny computer
  • Python and TypeScript (a better JavaScript) programming languages
  • making a web application (webapp) with the Flask framework
  • Hypertext Markup Language (HTML) and Cascading Style Sheets (CSS)
  • electronics fundamentals
  • connecting components on a breadboard
  • reading button presses
  • lighting multicolor LEDs

Smart Thermostat

Make a smart thermostat to control your home temperature.

Dave’s YouTube Electronics Playlist should provide more ideas.

The Teacher

Dave Briccetti is a highly skilled programmer and experienced computer science teacher. Watch him teach on his YouTube channel.

Bring to Class

Bring your own laptop computer running macOS, Windows, or Linux, or use one provided by the school. The school will provide hardware to use during the class, and you’re welcome to bring your own hardware.

2022-07-18

Computing in the News

The video game prescribed by doctors to treat ADHD

Circuit Wiring

Button Battery and LED

Button battery and LED Connect the LED’s long lead (wire) to the positive (+) side of the battery.

micro:bit

The micro:bit

Today we’ll start using the micro:bit. They have a lot of features, including:

  • LEDs
  • sound
  • sensors (light, heat, acceleration, etc.)
  • motor control ability

Breakout Boards

A breakout board makes it easier to connect a device such as the micro:bit to other components. It is easier to connect a servo motor to the micro:bit because the breakout board has headers, pins that connect directly to the servo’s female connectors.

Bit Board Basic

Trying Out the micro:bit

Use the USB cable in the kit to connect the micro:bit to your computer. Be gentle. The micro:bit should power up and then engage you for a few minutes in an interesting way that shows some of its features.

Connect to the Breakout Board

Gently insert the micro:bit into the connector on the breakout board.

Connect the Servo

Servo connection

Make a Program

We’ll use MakeCode.

Download Directly to the micro:bit (No Drag and Drop Needed)

This requires Chrome or Edge. Click on the gear icon and choose Connect device. Once connected, push Download and that’s all that’s needed.

Battery Pack

You can disconnect the micro:bit from the computer once you have it programmed, and instead power it from a battery pack. Connect the battery pack as shown here (red to +, black to -). When disconnecting, don’t pull the wires. Pull on the plastic piece instead.

Power connection

Play Time

Play with the servo, the LEDs, sound, the accelerometer, whatever you like! Make something.

Radio Communication

This is one of Dave’s favorite features. These devices can communicate with each other using radio transmissions. If we have time we’ll play with it.

Explore Tutorials and Play

2022-07-19

Computing in the News

BMW Wants to Charge for Heated Seats. These Grey Market Hackers Will Fix That.

Review of MakeCode

The micro:bit Radio Feature

p5.js

From their website: “p5.js is a JavaScript library for creative coding, with a focus on making coding accessible and inclusive for artists, designers, educators, beginners, and anyone else!”

Some of Dave’s Examples, for Motivation

The program we wrote:
Our program

Introduction to Python

print("Hello")
name = input('What is your name? ')
if name == 'Dave':
    print('Hello, master')
else:
    print('Nice to meet you,', name)

Getting Started with p5.js

2022-07-20

Computing in the News

Robot dog learns to walk in one hour
Robot dog

Python Adventure Game

  • Design places in Illustrator
  • Copy this code into your Coding Rooms workspace
  • Modify it to use your places and transitions
  • Make your own events

Introducing the Circuit Playground Express

2022-07-21

Computing in the News

Adafruit Show and Tell from 2022-07-20

We’ll watch during Free Learning Time.

Circuit Wiring

Lighting an LED On a Breadboard

A circuit on a breadboard

A circuit on a breadboard with power rails

TA Dorian Shows Electronics

  • Shift register with 7 segment display
  • 8-bit computer on breadboards

More with p5.js

2022-07-22

Computing in the News

A new twist on old-school animation

Circuit Wiring

Lighting an LED In TinkerCad Circuits

A circuit made with TinkerCad

Why do we need a resistor?

Arduino in Tinkercad Circuits

Burglar alarm

Burglar alarm

MakeCode micro:bit with Python

def on_logo_event_pressed():
    radio.send_string("Fun at water slides!")

def on_received_string(receivedString):
    basic.show_string(receivedString)

radio.set_group(1)
radio.on_received_string(on_received_string)
input.on_logo_event(TouchButtonEvent.PRESSED, on_logo_event_pressed)

2022-07-25

Computing in the News

Robots Learn Household Tasks by Watching Humans

micro:bit Radio

Treasure Hunt

There are nine micro:bits hidden in the building. They are running this code:

power = 1

def on_forever():
    basic.show_icon(IconNames.DIAMOND, 20)
    radio.set_transmit_power(power)
    radio.send_number(1)
    basic.clear_screen()
    basic.pause(2000)

def on_button_pressed_a():
    global power
    if power > 1:
        power -= 1
        basic.show_number(power)

def on_button_pressed_b():
    global power
    if power < 7:
        power += 1
        basic.show_number(power)

basic.forever(on_forever)
radio.set_group(1)
input.on_button_pressed(Button.A, on_button_pressed_a)
input.on_button_pressed(Button.B, on_button_pressed_b)

To find them, create this Beacon Detector and download it to a micro:bit. Connect a battery and start your search!

def on_received_number(value):
    strength = radio.received_packet(RadioPacketProperty.SIGNAL_STRENGTH)
    led.plot_bar_graph(Math.map(strength, -90, -60, 0, 9), 9)
    basic.pause(1000)
    basic.clear_screen()

radio.set_group(1)
radio.on_received_number(on_received_number)

Where They Were Hidden

Pictures of where the micro:bits were hidden

AT Tiny Demo

AT Tiny

Snap! Introduction

Snap! Web Site

Polygons

Dave’s Program

micro:bit with Python Traffic Signal Simulation

Traffic Signal Sim

Here’s some MakeCode Python code to get you started. Try to make a realistic simulation, but don’t wait a long time for the light to turn green.

def on_button_pressed_a():
    pins.digital_write_pin(DigitalPin.P0, 1)
    basic.pause(1000)
    pins.digital_write_pin(DigitalPin.P0, 0)

    pins.digital_write_pin(DigitalPin.P1, 1)
    basic.pause(1000)
    pins.digital_write_pin(DigitalPin.P1, 0)

    pins.digital_write_pin(DigitalPin.P2, 1)
    basic.pause(1000)
    pins.digital_write_pin(DigitalPin.P2, 0)
    
input.on_button_pressed(Button.A, on_button_pressed_a)

2022-07-26

Computing in the News

In warm-up for an AI Celine Dion, AI choir and dancers accompany human orchestra in Hong Kong concert

micro:bit with Python Traffic Signal Simulation

More explanation of the code

Traffic Light Simulation in Snap!

Project Image

Lots of Free Learning Time today

2022-07-27

Computing in the News

Tiny Handheld Boils Tetris Down to Its Bare Essentials

  • Uses the ATtiny85 microcontroller, just like Dave’s potentiometer and blinking light project

Quick Look at Dave’s Improved Traffic Signal Simulator

p5.js 3D

Dave’s Program

Free Learning Time

TA Dorian Shows Music Generation Software

Snap! Treasure Hunt Program

Dave’s Program

Free Learning Time

2022-07-28

Computing in the News

Employees Are Much More Concerned About Working in the ‘Metaverse’ Than Their Boss Is

Python in Coding Rooms

Project Euler #1

More Snap!

Creating a Polygon Block

Dave’s Program

2022-07-29

Computing in the News

Chips and Science Act, an ‘historic’ investment in U.S. innovation and tech, goes to Biden for approval

Finished Treasure Chest Program Explanation

Snap! Project

Make A Project using Circuit Playground Express or micro:bit

Ideas: