As of CircuitPython 7, PulseOut is no longer available on Gemma M0, so the Gemma M0 version of this project will not work.

You may be thinking, "Hey, this TV B GONE looks awesome, but I have a Gemma M0, can I get in on the fun?" Yes you can!

Here's what you'll need to build it:

1 x Gemma M0
Little round microcontroller
1 x IR LED
Super bright, 5mm 940nm
1 x Battery Holder
3x AAA with On/Off switch

1 x 2N7000 Transistor

4 x M3 x 8mm Screws and Nuts

Build the Gemma M0 TV B GONE

We could connect the IR LED directly to the Gemma M0, but it would have a pretty close range -- in order to boost the power, we'll use a transistor. The transistor will act as an amplifier to boost the current that flows through the LED.

Here's the circuit diagram we'll use.

We'll make all of the connections using M3 x 8mm screws and nuts.

  • First, take the transistor and carefully spread the legs as shown
  • Bend slightly hooked feet on the source and gate legs
  • Screw the source leg in place to GND and the gate leg to A0 as shown
  • Note how the drain leg is bent up a bit to connect later to the cathode leg of the IR LED
  • Next, bend hooks at the ends of both LED legs so they can be connected
  • Connect the shorter cathode leg with a screw and nut to the drain leg of the transistor as shown
  • Then, connect the longer anode leg connect to the Gemma M0's A0 pad

Power

The Gemma M0 TV B GONE needs power! You can plug in your AAA battery pack, and even affix the Gemma M0 to the case with some double sided foam tape.

Coding with CircuitPython

We'll code the Gemma M0 using CircuitPython. First, follow this guide https://learn.adafruit.com/adafruit-gemma-m0/circuitpython to get started with coding the Gemma M0 in CircuitPython. Install the latest release version of CircuitPython on the board.

You may also want to install the Mu editor https://learn.adafruit.com/adafruit-gemma-m0/installing-mu-editor for your coding needs.

Once you can successfully code in Mu and upload to the board, return here.

The program we'll use is quite small, but we do need to provide a large list of TV off codes as a separate text file on the Gemma M0. In order to save some space, we'll delete some unneeded things from the Gemma M0's CIRCUITPY drive: you can trash the Windows 7 Driver folder, as well as two items from the lib folder: adafruit_hid and neopixel.mpy.

Now, that there's enough space, download the codes file here as codes.txt onto the root of the CIRCUITPY drive.

This is the code for the Gemma M0 TV B GONE. Copy it and then paste it into Mu. Save the file as main.py onto your Gemma M0's CIRCUITPY drive (you can replace the existing main.py file) and it's ready to go!

# SPDX-FileCopyrightText: 2018 John Edgar Park for Adafruit Industries
#
# SPDX-License-Identifier: MIT

# Gemma M0 version of TVBgone!
import array
import time

import adafruit_dotstar
import board
import pwmio
import pulseio
from digitalio import DigitalInOut, Direction

# pylint: disable=eval-used

pixel = adafruit_dotstar.DotStar(
    board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
pixel.fill((0, 0, 0))

# Button to see output debug
led = DigitalInOut(board.D13)
led.direction = Direction.OUTPUT

pwm = pwmio.PWMOut(board.A2, frequency=38000,
                     duty_cycle=2 ** 15, variable_frequency=True)
pulse = pulseio.PulseOut(pwm)

time.sleep(0.5)  # Give a half second before starting

# gooooo!
f = open("/codes.txt", "r")
for line in f:
    code = eval(line)
    print(code)
    pwm.frequency = code['freq']
    led.value = True
    # If this is a repeating code, extract details
    try:
        repeat = code['repeat']
        delay = code['repeat_delay']
    except KeyError:  # by default, repeat once only!
        repeat = 1
        delay = 0
    # The table holds the on/off pairs
    table = code['table']
    pulses = []  # store the pulses here
    # Read through each indexed element
    for i in code['index']:
        pulses += table[i]  # and add to the list of pulses
    pulses.pop()  # remove one final 'low' pulse

    for i in range(repeat):
        pulse.send(array.array('H', pulses))
        time.sleep(delay)
    led.value = False
    time.sleep(code['delay'])

f.close()

It's ready for action! Turn it on and watch the TVs go dark!!

You'll see the onboard red LED blink every time a TV code is sent. It can take a some time for it to run through every code in the list, but the time it's done, there's a very good chance it has set some TV sets to sleep!

This guide was first published on Mar 18, 2018. It was last updated on Mar 18, 2018.

This page (Gemma M0 Variant) was last updated on Sep 27, 2023.

Text editor powered by tinymce.