If you are new to using Microsoft MakeCode, check out our guide to getting started.

We'll need to have the Crickit extension loaded to have the Circuit Playground Express and Crickit to work together. See this guide for the instructions.

The code below is the MakeCode for driving the Peltier Module. It's got a lot going on, let's break it down. The Temperature sensor and the potentiometer are connected to analog inputs on the Circuit Playground Express. The first 4 set blocks convert the analog voltage read (from 0 to 1023) to the temperature and a number of seconds from 0 to 10 for timing the Peltier cycle.

Note: In CircuitPython the number of possible values from analog reads are 0 to 65532, in MakeCode only 0 to 1023, in case you are comparing the code.

If the Peltier cool_time is less than a second, we ensure it's either zero or one as we don't want to cycle the module less than a second at a time as it does not like fast cycle times.

The values are printed out in the Windows 10 app if running via console log blocks.

The next if block will stop the Peltier for cool_time seconds and run it for (10 - cool_time) seconds. As the pause block is in milliseconds, we multiply the number of seconds by 1000.

The function Display shows the number of seconds the Peltier is running off. If Button A is pressed, the display is switched to temperature from 32 to 82 degrees with each light 5 degree steps. Pressing Button A again switches back to the seconds dialed in by the Potentiometer.

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

This page (MakeCode) was last updated on Feb 20, 2021.

Text editor powered by tinymce.