From Simple Equations to Complex Behavior

Another excellent video from Veritasium. Starts with the logistic equation and through a series of very clear examples gets to the relationship between growth rate (r) and equilibrium population. He does go into how this graph relates to the Mandelbrot set, but the rotating graphs are a little tricky to follow. However, the discussion of the practical applications of chaos theory (at 10:35) is really nice as well.

Note:

The logistic equation:

 x_{n+1} = r x_n (1-x_n)

gives the new population (xₙ₊₁) for a given growth rate (r) and the old population (xₙ).

This makes for a fairly nice and easy programming assignment.

PlottyBot: Pen Drawn Plots

The PlottyBot project looks like a nice introductory project for building computer controlled devices, like 3d printers, laser cutters, and CNC machines. It draws designs using a pen, and is built off a Raspberry Pi Zero, which I’ve been using a lot.

A PlottyBot in action (from https://ben.akrin.com/?p=10244)

It’s now on my list of potential Makerspace Projects.

Calculating π

A very good explanation of how Newton applied calculus to come up with a much more efficient method of calculating pi (π). It starts with a nice illustration of the relationship between π and the area of a circle, moves explains the binomial theorem (quite nicely), and then shows how Newton generalized the binomial theorem to come up with an integral of a quarter of a unit circle. They don’t explain what a unit circle is, but that’s easy: it’s just a circle with a radius of 1.

Extracting Gold from Computer Parts

An interesting demonstration of how gold can be extracted from printed circuit boards (PCB’s) and RAM trimmings (which I did not know was a thing). The yield is low, but NileRed gives full detail, including the chemical equations, which is why I may show this to my chemistry class.

LED Light Strip with Pi Zero

Raspberry Pi Zero controlling a LED strip, with a hardwired clear button.

I wanted to set up a small (20 LEDs) light strip using a Raspberry Pi Zero, so students could learn how to remotely log in to a device, work with the Linux command line, run python programs, and get visible, real feedback on their progress.

Instructions and code are in the Github rpi-led-strip repository.

Web control for the LED strip.

The repository also has instructions and code for setting up a local server on the Pi so you can control the LED strip via a webpage. Students working on their own LED projects in the Makerspace will appreciate this.

The main idea here was to make the project as simple as possible. The web page is basic with minimal styling, so it should be easy to edit, but I do test out some of the newer HTML input elements, like the color picker. The README in the repository also includes instructions on how to, step by step, add components to the webpage to control the Pi: the “Blue” button is used as the example (it sets the entire strip to blue).

With only 20 LEDs you don’t need an external power supply so everything can be run through the Pi.

Adafruit’s CircuitPython NeoPixel library makes controlling the lights really easy. There are a few example programs in the rpi-led-strip/pyLED/ directory of the repository.

The full strip.

I’ve also included a physical button (it’s optional) that I’m using right now to just clear the LED strip. I may change it to just reboot the Pi, because I anticipate that things will get interesting when I have an entire class trying to connect to one or two devices. So far, I’ve had a small group of four students try this with some success.

HTML Animations using SVG

A basic animation test using the HTML SVG element instead of the CANVAS. This one uses the svg.js library. This library has it’s own, built in animation function that is used to make the red rectangle move back and forth (1 second period).

The green circle is moved using the requestAnimationFrame function with some coding to make it bounce back and forth.

<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <script src='./svg.js/svg.min.js'></script>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <div id="svgPlace"></div>
  </body>

  <script type="text/javascript">
    var draw = SVG().addTo('#svgPlace').size(300,400);
    var line = draw.line([[20,20],[200,20]]).stroke({width: 1, color:'#f00'});

    //Metronome red rectangle.
    rect = draw.rect(50,100).move(200,20).fill('#f00');
    rect.radius(10);
    dir = 'left';

    setInterval(animate, 1000);
    function animate(){
      if (dir === 'left'){
        px = 20;
        py = 20;
        dir = "right";
      }
      else {
        px = 200;
        py = 20;
        dir = "left";
      }
      rect.animate({
        duration: 1000,
        when: 'now'
      }).move(px,py);
    }

    //Green circle
    circ = draw.circle(20).fill('#0f0').move(250,10);
    window.requestAnimationFrame(animateCirc);
    cx = 250;
    cy = 20;
    dy = 1;

    function animateCirc(){
      cy+=dy;
      circ.move(cx,cy);
      window.requestAnimationFrame(animateCirc);
      if (cy > 100 ){
        cy = 100;
        dy = -dy;
      } else if (cy < 20) {
        cy = 20;
        dy = -dy;
      }
    }

  </script>
</html>