Close

MakeTime as instrument display

A project log for MakeTime

Arduino-compatible development platform whose primary function is a clock

mihaicuciucmihai.cuciuc 09/25/2021 at 09:210 Comments

You can use MakeTime as an indicator for your PC's performance. Or for anything else, for that matter. Here's an example of it being used as a CPU load monitor

or you can use more than one to make an instrument cluster

MakeTime is simply listening on the serial port for what it should be displaying and a python script sends the stats.


Arduino sketch

#include <Adafruit_NeoPixel.h>

#define LED_PIN    9
#define LED_COUNT 24
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);


void setup()
{
  strip.begin();
  strip.show();
  Serial.begin(115200);
  Serial.setTimeout(100);
}

void loop()
{
  String s;
  int r, g, b, i;
  uint32_t color;
  s = Serial.readString();
  if (s != "")
  {
    sscanf(s.c_str(), "%d %d %d", &r, &g, &b);
    strip.clear();
    for (i = 0; i < 19; i++)
    {
      color = 0x00101010;
      if (r > i) color += 0x600000;
      if (g > i) color += 0x006000;
      if (b > i) color += 0x000060;    
      strip.setPixelColor((i + 15) % 24, color);
    }
    strip.show();
  }
}

 
Python script for CPU load monitor

import serial
import psutil

serialPort = serial.Serial("COM6", 115200, xonxoff=False, rtscts=False, dsrdtr=False)

while (1):
    cpu_percent = psutil.cpu_percent(interval=0.2)
    str = "%d 0 0" % int(cpu_percent*19 / 100.0)
    bstr = bytearray(str)
    serialPort.write(bstr)
    print cpu_percent, bstr


serialPort.close()

Discussions