July 4, 2014

Lorenz Attractors: The Basics

A Lorenz attractor is a chaotic system that simulates a simplified weather pattern. It describes convection currents in a a block of air heated from below and cooled from above. Here is a picture of a Lorenz attractor:



What does it mean to be a "chaotic system?" Put simply, the system must never follow a pattern that repeats, and it must have a strong dependence on the initial conditions. I will explain more about the latter in a future post.

To help explain the fact that chaotic systems follow a non-repeating pattern, watch this video of the above Lorenz attractor as it is drawn on the screen:



The motion appears to be random, for the particle switches between the two sides unpredictably. For most intents and purposes, you could call that "random." However, there is a difference between chaos and true randomness. Chaotic motion, while unpredictable, follows a clear formula. True randomness cannot be described by equations.

July 3, 2014

More Dot Matrix Magic

Today I made two last demos with my dot matrix before I clear my breadboard to try out some new things that I recently ordered!

The first is a simple animation of diagonal lines, made for a friend:


The second is something of my own design to try to use a photoresistor with my Arduino. A photoresistor is a simple type of light sensor. It can detect how much light is falling on the sensor. When the sensor does not detect much brightness, the display shows a green moon. When a light is shone on the sensor, the display switches to a red sun! For a simple sensor demo, this is probably my favorite one so far!

July 2, 2014

Lorenz Attractor Day 1

Today I did some major work on the Lorenz Attractor program. It's far from done, but I was able to draw the fractal on the screen in 3D. Here are a few nice intermediate screenshots:






I finished transcribing the code from the book I have, and then started rewriting it for a number of reasons:
  1. The original code calculated positions component-wise; the code was repeated three times for the x, y, and z direction. In my version of the program, I used vectors which do all three directions at once.
  2. The old code was repeated three times for three different 2D projections of the 3D system. In my program, I drew the curve with 3D graphics, so most of the old code was irrelevant to me. 
  3. The old code had a bad coding style. Numbers were entered into the code directly, which by modern standards is bad coding practice. I am fixing this with named variables and constants in my program.
I realize that these problems are due to the book being about 25 years old. It's an interesting programming challenge to update the code to modern standards.

Tomorrow I will discuss the Lorentz Attractor in more detail to explain what this fancy chaos really means!

Today I also got another order of electronics parts. I ran a test of one of two infrared (IR) sensors to see how they work. Here are the results:
Eventually I will use the sensor in tandem with my Arduino board. However, I have a few last tricks up my sleeve for my dot matrix! Stay tuned!

July 1, 2014

Digital Fire

Today I managed to plan out my digital fire program, and it works really nicely! Here's a screenshot...


...and a video:

I did not get much work done on the Lorenz Attractor, the code is a little out-of-date so it's harder to interpret. It's also funny how bad the author was at making readable code. I'm not even a professional programmer and I could have made the code neater and a bit more efficient.

June 30, 2014

Up Next: Arduino and Fire and Fractals

Today was the first day in quite a while where I didn't do any programming. Yet I have a couple of ideas for the next day I can sit down and code:

While I still have my dot matrix set up on my breadboard, I am thinking of making an Arduino fire animation. It will be two or three frames long. Since I have a button hooked up to the board, I will make it into a "lighter." press the button once or twice and it only displays the fire animation while the button is held down. Press the button a few more times and the flame will persist even when the button is released.
I also went to a book sale today, I found a book on fractal programming in C! It's humorous to read the book talk about late '80s computer hardware, yet interesting. The fractal algorithms work the same even in more modern programming languages. It's a visual form of chaos theory, it's really fascinating.

Over the next few days, I'll start to program the first fractals in the book, Lorenz Attractors. Here's a screenshot from the book.


My version will hopefully be in 3D and will be animated to get a better feel for the chaotic patterns involved.

June 29, 2014

Summer of Arduino

Wow, it's been forever since I last posted here. Oh well, no better time than the present to get back in the swing of things.

Lately I've been programming stuff for Arduino. I've been making code libraries to control various displays and sensors. Eventually I'll put these to use in interactive games and demos using my PC, Arduino, and various electronic components.

In the meantime, here is the playlist where I've been posting things that I make with Arduino: Arduino YouTube Playlist

June 3, 2013

Vectors: What is a Vector?

This first tutorial on vectors will explain what vectors are in contrast to scalars in physics