Minecraft Server Glowing Status Cube

I made this for the eldest boy as a Christmas present.

It is based of the following cube: https://www.thingiverse.com/thing:524925

I printed it at 150% size and added an ESP8266 with a LED strip containing 4x LEDS.

It works by connecting to my server which runs a node app. The node app periodically checks the number of players on my server:

setInterval(updatePlayers, 1000*15);
var numberOfMineCraftPlayers = 0;
url = "https://api.mcsrvstat.us/2/myserver.myserver.com";
async function updatePlayers() {
    https.get(url,(res) => {
        let body = "";

        res.on("data", (chunk) => {
            body += chunk;
        });

        res.on("end", () => {
            try {
                let json = JSON.parse(body);
                console.log(json);
                numberOfMineCraftPlayers = json.players.online;
                console.log(`Number of online players: ${numberOfMineCraftPlayers}`)
            } catch (error) {
                console.error(error.message);
            };
        });

    }).on("error", (error) => {
        console.error(error.message);
    });
}

This updates the number of players variable with serves a simple GET route:

app.get('/minecraft', function (req, res) {
    let jsonData = { "players": numberOfMineCraftPlayers};
    res.json(jsonData);
});

On the Arduino/ESP8266 side the program works like this:

  1. Connect to WiFi
  2. Get number of players
  3. Divide the color spectrum into 8 parts
  4. Depending on the player dedicate a chunk of that color spectrum
  5. Iterate through each “hue” and use a sine wave function to change brightness
  6. Loop again

Here is the code:

#include <FastLED.h>
#include <ESP8266WiFi.h>        // Include the Wi-Fi library
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>

const char* ssid     = "";         // The SSID (name) of the Wi-Fi network you want to connect to
const char* password = "";     // The password of the Wi-Fi network

// How many leds in your strip?
#define NUM_LEDS 5
#define DEVISIONS 8
// For led chips like WS2812, which have a data line, ground, and power, you just
// need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
// Clock pin only needed for SPI based chipsets when not using hardware SPI
#define DATA_PIN D1
#define CLOCK_PIN 13

// Define the array of leds
CRGBArray<NUM_LEDS> leds;

void setup() {
  FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);  // GRB ordering is typical
  Serial.begin(9600);         // Start the Serial communication to send messages to the computer
  delay(10);
  Serial.println('\n');

  WiFi.begin(ssid, password);             // Connect to the network
  Serial.print("Connecting to ");
  Serial.print(ssid); Serial.println(" ...");

  int i = 0;
  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
    delay(1000);
    Serial.print(++i); Serial.print(' ');
  }

  Serial.println('\n');
  Serial.println("Connection established!");
  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP());         // Send the IP address of the ESP8266 to the computer

  leds[0] = CRGB::Red; // shows green
  leds[1] = CRGB::Green; // shows red
  leds[2] = CRGB::Blue;
  FastLED.show();
  delay(5000);
  leds[0] = CRGB::Black;
  leds[1] = CRGB::Black;
  leds[2] = CRGB::Black;
}

void loop() {

  WiFiClient client;  // or WiFiClientSecure for HTTPS
  HTTPClient http;

  // Send request
  //http.useHTTP10(true);
  http.begin(client, "http://yourclient.com");
  http.GET();

  // Print the response
  // Serial.print(http.getString());

  // Parse response
  DynamicJsonDocument doc(2048);
  deserializeJson(doc, http.getStream());

  int players = doc["players"];
  Serial.println(players);
  // Serial.println(doc["port"]);


  // Disconnect
  http.end();

  // Now turn the LED off, then pause
  static uint8_t hue;
  //players = 5;

  if (players > DEVISIONS) {
    players = DEVISIONS;
  }
  int minHue = (256 / DEVISIONS) * players;
  int maxHue = ((256 / DEVISIONS) * players) + (256 / DEVISIONS);

  for (hue = minHue; hue < maxHue; hue++) {
    for (int i = 0; i < NUM_LEDS; i++) {
      // fade everything out
      leds.fadeToBlackBy(40);

      // let's set an led value
      leds[i] = CHSV(hue, 255, 255);
      FastLED.delay(16);
      Serial.print("Hue: ");
      Serial.println(hue);
    }
    for (int r = 0; r < 360; r++) {
      float angle = radians(r);
      int brightness = (255 / 2) + (255 / 2) * sin(angle);
      FastLED.setBrightness(brightness);
      //Serial.print("Brightness: ");
      //Serial.println(brightness);
      FastLED.delay(16);
      FastLED.show();
    }

    FastLED.show();
  }
  //delay(1500);
}

I didn’t put a lot of time into this. But it works as intended.

Dingbat.app

Dingbat.app is a fully functioning web app written using Laravel and Livewire. At the moment it has the following functionality:

  • User signup/registration
  • Custom workout logs
  • Create workout plans:
    • Custom number of weeks
    • Custom number of days per week
    • Custom number of workouts/cardio per week
    • Custom number of exercises per workout
    • Add the following to exercises:
      • Time Under Tension (Tempo)
      • Rest Between Sets
      • % of One Rep Max (ie 65% 1RM)
      • As Many Reps As Possible
      • Sets/Reps
  • Follow pre-programmed workout plans including:
    • nSuns 4,5,6 days splits
    • Wendler 5,3,1
    • Metallicadpa PPL split (6 workouts per week)
    • Strong Curves
  • Follow multiple plans simultaneously using Plan Chooser
  • Specify custom start dates for all plans
  • Start plans on any day of the week
  • Modify per week settings of existing plans (change workout days)
  • See per plan statistics
  • See per week statistics
  • See per exercise statistics
  • Create goals for all types:
    • Skin fold
    • Body measurements
    • Strength and repetitions (for any exercise type)
  • Calculate Parillo, Durnin and Jackson Pollock skin fold tests
  • Measure and track body fat percentage, weight, skin folds and measurements

Wendler 5-3-1, nSuns and PHUL on dingbat.app

I’ve upgraded dingbat.app to support the following:

  • One Rep Max
  • Time Under Tension
  • Rest Per Set
  • AMRAP

Due to these upgrades it can now support Wendler, nSuns and PHUL workout splits…

I’ve upgraded the wizard to support these upgrades.

You can see the workout volume for a full month on PHUL (using 100kg per exercise):

As before the dashboard automatically calculates the weight per set if One Rep Max is configured. Simply click on the exercise and it will take you to the add sets page with the values preconfigured:

Track your workouts, follow workout plans at Dingbat.app

https://dingbat.app has really exploded in functionality and size. I have spent quite a bit of time adding features that I always wanted in a workout app.

The feature list so far:

  • Daily dashboard showing muscles targeted by the workout
  • Follow workout plans
  • View workout history
  • Automatic 1RM calculation and record keeping
  • Rich graphs and per exercise history showing volume and 1RM
  • Record and track a large list of measurements (weight, body fat, dimensions)
  • See weekly compliance vs workout plan
  • See weekly volume
  • See per set and per sub-workout performance
  • See weekly volume, reps

The website is responsive so it works with all screen sizes.

I will be announcing a MAJOR update soon so stay tuned.

BTW dingbat.app is designed to help you with your workout compliance and strength progression. It is and will always be free.