Short link to this page: bit.ly/db-tas-8
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.

Classroom Resources

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-06-13

Computing in the News

Introducing GTGraffiti: The Robot That Paints Like a Human

Circuit Wiring

Button Battery and LED

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

Lighting an LED On a Breadboard

A circuit on a breadboard

Thanks to BJC

The micro:bits, breakout boards, and batteries are provided by The Beauty and Joy of Computing.

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.

Here’s Dave’s example.

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-06-14

Computing in the News

The Floppotron 3.0 Now Uses a Whopping 512 Floppy Disk Drives as Part of Its Outdated Tech Orchestra

Circuit Wiring

Lighting an LED In TinkerCad Circuits

A circuit made with TinkerCad

Why do we need a resistor?

BJC Hardware Unit

Course Page

MicroBlocks Introduction

MicroBlocks is an alternative to MakeCode. One advantage is that you don’t have to download code to the micro:bit. It’s live.

BJC Meet micro:bit

Game Play

Students made games from the BJC hardware unit. Some made the fast clicker game. Others made the basketball game.

BJC basketball game

Remote Control Tilt Servo Project

Using both Python and blocks, we created a micro:bit remote controller that sends its current X acceleration (“bank” tilt) to another micro:bit by radio. Then we created a receiver program that displays the tilt from the other micro:bit. We’ll continue tomorrow.

2022-06-15

Computing in the News

New Research Suggests Always-On Bluetooth Could Be Used to Track Your Phone

Python Fundamentals

print, input, if/elif/else, in

Remote Control Tilt Servo Project, Continued

Let’s have the micro:bit that receives the messages use them to control a servo motor.

Circuit Playground Express

We’ll try out these microcontrollers. We’ll use MakeCode for Adafruit.

2022-06-16

Computing in the News

Interpol Nabs $50 Million and 2,000 Alleged Scammers in Crackdown on Social Engineering Seized devices

Assembling Gates

Some may want to hot glue one of these together. An assembled gate

2022-06-17

Computing in the News

This Custom Self-Extending Cardboard Lightsaber Doesn’t Require Any Imagination

Python Fundamentals Review

SOS Blinker

SOS game

Free Time Activities

2022-06-20

Computing in the News

How DOJ took the malware fight into your computer

Reaction/Memory Game

We’ll start working on a multiplayer game where you have to push buttons matching a sequence received from the game server (another micro:bit), and be correct, and be faster than the other players. Sequence game

Server Code

sequence_length = 2

def make_sequence() -> str:
    global sequence_length
    seq = ''
    for _ in range(sequence_length):
        seq += '12'[randint(0, 1)]
    sequence_length += 1
    return seq

def send_sequence():
    radio.send_value("pattern", int(make_sequence()))
    
def on_received_value(name, value):
    if name == 'winner':
        basic.show_number(radio.received_packet(RadioPacketProperty.SERIAL_NUMBER))
        basic.show_icon(IconNames.HEART)
        basic.pause(1000)
        basic.clear_screen()

radio.on_received_value(on_received_value)
input.on_logo_event(TouchButtonEvent.PRESSED, send_sequence)

Client Code

current_seq = ''
responding = False
remaining_seq = ''

def on_received_value(name, value):
    global remaining_seq
    if name == 'pattern':
        for letter in str(value):
            if letter == '1':
                basic.show_leds("""
                ##...
                ##...
                ##...
                ##...
                ##...
                """)
            else:
                basic.show_leds("""
                ...##
                ...##
                ...##
                ...##
                ...##
                """)
            basic.clear_screen()
            basic.pause(100)
        responding = True
        remaining_seq = str(value)

def check_for_win():
    if not remaining_seq:
        radio.send_value("winner", 0)
        basic.show_icon(IconNames.HEART)
        basic.pause(2000)
        basic.clear_screen()

def process_response(button_char: str):
    global remaining_seq
    if remaining_seq:
        if remaining_seq[0] == button_char:
            remaining_seq = remaining_seq[1:]
            check_for_win()
        else:
            basic.show_icon(IconNames.CONFUSED)
            remaining_seq = ''
    
def on_button_pressed_a():
    process_response('1')

def on_button_pressed_b():
    process_response('2')

radio.on_received_value(on_received_value)
input.on_button_pressed(Button.A, on_button_pressed_a)
input.on_button_pressed(Button.B, on_button_pressed_b)

Learning Python using Turtle Graphics (on replit)

Python Turtle Graphics

2022-06-21

Computing in the News

Seaweed and 3D printers: Chile’s innovative approach to feeding kids

Setting individual pixels on micro:bit and Circuit Playground Express

Sound Level Meter

2022-06-22

Computing in the News

Microsoft’s Calling It Quits on Creepy Emotion Recognition Tech

RGB and Human Vision

Setting individual pixels on micro:bit and Circuit Playground Express

Ambient Light Meter

More Python with Turtle Graphics

Student draws something and we all make it in turtle graphics

Programming Arduino using TinkerCad Circuits

TinkerCad

Snap!

Quick Looks at Blender and Unity

2022-06-23

Computing in the News

Hot Tub Crime Machine: Jacuzzi Smart Tubs Left Personal Info Exposed

Math Quiz Game in Python

In repl.it

Up and Down Counter for micro:bit in Python

2022-06-24

Computing in the News

Bandai’s New Digimon Watches Only Beef Up Their Monsters When Kids Exercise

Ultrasonic Rangefinder

Guide from Arduino Let’s build this in the Tinkercad simulator, then with a real Arduino Uno.

Free Time Activities

  • MakeCode for micro:bit or Circuit Playground Express
  • MakeCode Arcade
  • TinkerCad Circuits
  • Create a game with micro:bit or Circuit Playground Express
  • Python practice
  • 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