We'll be using CircuitPython for this project. Are you new to using CircuitPython? No worries, there is a full getting started guide here.

Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython. You can learn about Mu and its installation in this tutorial.

Get the code from GitHub, place it in Mu and save it onto the Circuit Playground Express as `code.py` (not `hot.py`!)

```# SPDX-FileCopyrightText: 2018 Anne Barela for Adafruit Industries
#

import time
import board
import neopixel

pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, auto_write=False)

def show_value(heat_val):         # Show throttle on NeoPixels on CPX
num_pixels = int(10 * (heat_val + 0.002))
for i in range(num_pixels):
pixels[i] = (10*(i+1), 0, 0)
for i in range(num_pixels, 10):
pixels[i] = (0, 0, 0)
pixels.show()

TMP36 = AnalogIn(board.A3)  # TMP36 connected to A3, power & ground
POT = AnalogIn(board.A7)    # potentiometer connected to A7, power & ground

while True:   # Loop Forever

voltage = TMP36.value * 3.3 / 65536.0  # Read temp sensor, get voltage
tempC = (voltage - 0.5) * 100.0        # Calculate Celsius
tempF = (tempC * 9.0 / 5.0) + 32.0     # Calculate Fahrenheit

heat_value = POT.value / 65536.0   # Value (0.0 to 1.0) to drive pad

print((tempF, heat_value))         # Display temperature and drive
show_value(heat_value)

heating_pad.throttle = heat_value  # set Motor throttle value to heat_value

time.sleep(0.25)                   # Wait a bit before checking all again
```

If you open the Mu serial terminal (press the menu bar Serial button), you'll see the temperature measured by the temperature sensor and the value of the potentiometer from 0 to 1. At 0, the heating pad is not powered, at 1.0 it is fully powered, and values between the heating pad is pulse width modulated to be at at a temperature lower than maximum.

The NeoPixels show the value of the potentiometer in 1/10th increments. The more NeoPixels, the hotter the heating pad.

This guide was first published on Sep 11, 2018. It was last updated on Sep 11, 2018.