September 12, 2014

The Road Ahead

I haven't been posting much lately, simply because I haven't been programming much in my own time the past couple of weeks. I packed away my microcontrollers because I move in to Drexel next week!

Besides work keeping me busy, I have also been trying various distributions of Linux from live CDs/DVDs. I went a little overboard, I can choose a different operating system every day... for two weeks in a row! Yet it is a good to see the various distributions and evaluate which ones are best for me.

Probably my favorite so far is Xubuntu. More light than Ubuntu, and the particular version of Xfce makes for a nice clean desktop interface.

As for programming, I have no idea what I will be doing next. I need to focus on transitioning to college first, then I'll choose something to work on.

Some possibilities:

  • Try out the Adafruit Neopixels I bought
  • Try out new I2C sensors such as an IMU (position sensor that measures acceleration, rotation, and orientation with respect to the Earth's magnetic field
  • Try again at making a serial library
  • Try using bluetooth to control a single-board computer (BeagleBone Black or Raspberry Pi) from an Android phone
  • Or maybe something else entirely!

September 10, 2014

Sig Figs Explained

Today I noticed one of my friends were having trouble with significant figures in chemistry. Here is a post to help people figure out some of the more ambiguous cases.

Case 1: Inexact quantity

Suppose we have some sort of salty food. On the label it says:
"Sodium: 300 mg"

Sig Figs: 1

Why: Due to rounding in the label and the fact that each serving might not have exactly the same proportions, you could easily have 290 mg, 320 mg, 310 mg, or anything that's between 250 and 340 mg. Otherwise, the number would be 200 or 400 mg. Since we can't figure out what the tens or ones place is, the only digit we know is exact is the 100s place, hence 1 sig fig.


Case 2: Exact quantity

Suppose we are counting ducks in a pond. We count them a few times to make sure we have an exact count:
"1, 2, 3, 4, ... 298, 299, 300"
"1, 2, 3, 4, ... 298, 299, 300"
"1, 2, 3, 4, ... 298, 299, 300"

Sig Figs: Infinite

Why: This is an exact count. You are absolutely sure that you do not have 299 or 301 or 302 or 300.5 ducks, so there is no uncertainty. It is not 3 sig figs, for we know that the tenths place is 0. it's not 4 sig figs for we know that the hundredths place is also 0. In fact, we know that there are 300.00000000000000... ducks on the pond.

Case 3: Defined Quantity

The conversion factor from inches to centimeters is defined as:
2.54 cm = 1 in.

Sig Figs: Infinite

Why: The conversion factor is a definition; there is no uncertainty. Even though the number goes to 2 decimal places, there is no possibility of 2.55 cm equaling 1 inch due to the way that the quantities are defined.

Case 4: Textbook Ambiguity

Suppose a textbook problem talks about a 300 L tank of water.

Sig Figs: Depends. 1 if interpreted as a measurement, infinite if interpreted as a definition.

Why: This really depends on the textbook.

Some textbooks might treat it as a measurement. Then it would be one sig fig for it might not be exactly 300L in real life.

Other textbooks might give an answer with more sig figs than should be needed. If so, it is either because they treat it as a theoretical example where numbers can be exact, or just provide extra sig figs so you can check your math before rounding.

All in all, check your textbook carefully. If the questions denote different numbers of sig figs differently, they probably treat numbers as measurements. If not, the textbook might treat it as a definition.

If you are not sure, talk to your teacher.

Avoiding Ambiguity

When writing numbers, there's a number of conventions to help determine how many sig figs for a measurement. Take these for example:

300 - 1 sig fig
300. - 3 sig figs. the decimal shows that we know up to the decimal place for certain
300 - 2 sig figs. an underline explicitly shows the last significant figure.
3x10^2 - 1 sig fig. In proper scientific notation, every number shown on the left of the x is significant.
3.0x10^2 - 2 sig figs. Same rule as the previous example.

I hope that helps to explain some of the more challenging aspects of sig figs, particularly zeros. 

August 28, 2014

LED Pulse Network: Part 3

Today I managed to get 2 out of 3 devices to talk together properly. When the chipKit receives a pulse message, it lights up its LEDs, then sends a message to the Teensy++. The Teensy++ does the same thing.



Right now I am using a Python script to control the system, eventually the Arduino will control everything.

Here is a vid of the demo in action:


August 25, 2014

LED Pulse Network: Part 2

Lately I've been working on the serial communication portion of the pulse network I am making. The details get rather technical, but so far it is going well. I am testing one device at a time before I start wiring devices together. 

In this test, I made my chipKit respond to certain serial messages by turning on its on-board LEDs or pulsing the light through the line of LEDs forwards or backwards. 

I then put together a quick Python script to help automate the testing process. It gives me a command prompt and I can type one of the following commands to send messages to the device:

on - turn the on-board LEDs on
off - turn the on-board LEDs off
pulse forwards - "pulse" through the LEDs in the forwards direction
pulse backwards - "pulse" through the LEDs in the backwards direction

Here is a video:

August 22, 2014

LED Pulse Network: Part 1

Today I finally got around to starting a new project: making a ring network of three Arduino-compatible boards so they can talk to each other and pass around a "pulse" of light that will be displayed on a large number of LEDs.

Today I just set up the LEDs and made a rough sketch of the LED animation. Here's a pic of the setup:
I would have made an actual ring shape of LEDs, but considering that my other breadboards are currently in use, it was easiest to just wire them in rows. 

Currently, each device is its own separate circuit. Soon that will change, I will connect them together soon.

In the meantime, here's a video of the lights in action:



August 21, 2014

Invisible Light

Ever wonder what it's like to see infrared and ultraviolet light? Our eyes cannot detect such wavelengths of light just outside the range of visible light. Yet cameras can detect both types of light!

Check out this picture (Left LED is infrared, the right LED is ultraviolet)

The dark LED on the left is an Infrared LED. the pinkish/purplish white dot in the center is infrared. Here's a better picture taken from above with the UV light off:
In real life, the IR LED doesn't look like it turned on at all. The dark plastic filters out everything except UV. It's only when you use a digital camera (phone cameras work just fine!) that you can "see" the light.

To try this at home: get a TV remote and look at the end of it with a camera as you press buttons. You'll see pulses of IR light!

The UV LED (or black light if you wish) does emit visible light in the violet range, so it appears to be a purple LED. However, when you look at it through a camera, you see that there's way more light to be had, which is why in a photo it seems to glow so brightly!

This one is a bit harder to try at home, but if you ever go to a party with black lights, try taking pictures of the black light bulbs!

August 20, 2014

Dabbling With Yet Another Microcontroller

Finally got a chance to try out my Parallax Propeller QuickStart microcontroller. The programming language it uses is unusual to me, as it is closer to assembly language compared to C/C++ which is used in Arduino and other microcontrollers. Yet it's pretty cool to learn.

I also like how this board has 8 surface mount LEDs on it, makes it easy to test things without needing to find the right LEDs, resistors and jumper wire for the job.

Here's a vid of one little test I made:

Notice how the lights blink so fast it appears like it is a solid light! This effect is called Persistence of Vision (POV). 

August 4, 2014

A Key to the Floodgates of Awesome

Today I finally figured out how to run Python scripts from a Node.js server. Usually that would be unnecessary, but I find it useful. I will write BeagleBone Black programs in Python, Ruby, or Bonescript. The server will be able to run any of the above to allow browsers to interact with circuits.

Here is a video of the circuit and accompanying web page. The server gets a reading from the rotary encoder (the glowing cyan knob) and then controls the blue circle's position on the web page.

This demo is not very exciting, but it is key to learning about the BBB's web server. This is only the beginning. Imagine what can be done with electronic circuits and a full-featured web server? On top of this, imagine when I add in an Arduino Uno or two! The fun doesn't seem to want to end! Stay tuned for more!

August 2, 2014

Since When Did I Acquire So Many SD Cards??

Nothing new to show today, I was working hard at learning how Node.js and Socket.io work. I think I finally figured it out, but I will try it out tomorrow.

I did stop to consider one thing today: when did I acquire so many SD Cards?
Not Pictured: a μSD card in the phone that was used to take this picture

August 1, 2014

More Fractals and a Web Server

The other day I decided to try another fractal from the fractal programming book I have. Here are the results!


I also continued to try out my BeagleBone's web server! This video doesn't look like much, but it really shows the power of what even small web servers can do!

Basically, I start by running a Node.js script. It does three things:

  1. Runs a Ruby script which blinks the LEDs in order
  2. Runs a Python script which flashes 1 LED in an SOS pattern
  3. Hosts a web page that can be accessed from the local network. The web page has two buttons, one turns all the lights on, one turns them off.
This demo uses many different languages: HTML, JavaScript, Python and Ruby. That's my favorite part about web servers like this, it lets you get multiple types of programming language to communicate with each other!

July 31, 2014

Temperature Sensor: It Works! Sorta...

Sorry for the delay, orientation at Drexel and work have kept me busy.

I finished up the temperature-sensitive Arduino circuit last week. Each individual component works the way that I wanted it to. The only problem is controlling the temperature to get a good video.

Here's a video. Not the greatest, but it is what it is:


I also started to try out my new BeagleBone Black! Here's one of my first test runs:


Obviously there is much to come from my BeagleBone Black. I hope to set up a web server that can let me control BeagleBone Black pins from web apps! And someday I will probably make serial networks between the BBB, Arduino boards, and maybe even a Raspberry Pi someday!

July 22, 2014

Temperature Sensor Day 2

Today's the second day where I added to my temperature sensor. I didn't do any coding, but I wired the circuit together completely. It was quite a task, as there were many components and scores of wires to connect.

Here's a picture:

I've also been programming for my part-time job, as well as continuing to try the roguelike tutorial I found. All is going well so far.

July 21, 2014

What's That Whirring Noise?

Today I tried out the first portion of my temperature dependent circuit! I tried using a motor with my Arduino for the first time. It's also the first time I've used an external power source in addition to the Arduino's 5V output pin. All went well, no fried circuits!

Here's a video:

I also started a roguelike in Linux today! It's going to take a long time to get visual results, so I will focus mor on my Arduino thermostat!

July 20, 2014

Plans for a Arduino Temperature Sensitive Device

Today I didn't get to do any programming, but I planned out my next Arduino project! It will use an analog temperature sensor. Here is what it will do:

  • An RGB LED will light up blue if the temperature is below room temperature. the LED will light up red if the temperature is above room temperature
  • The current temperature will be displayed on a 4-digit 7-segment display
  • A switch will let the user choose between °F and °C for the display
  • If the temperature goes above 80°F, a button with a built-in LED will start blinking
  • If the button is pressed while the LED is blinking, a motor will turn on.
  • The motor will be have an attachment to make a makeshift fan. The fan will blow on the temperature sensor to try to cool it down
  • Once the temperature reaches 75°F (or some temperature between room temperature and 80°F), the fan will turn off.
Expect to see some demos in the near future as I try out the 7-segment display I soldered, the temperature sensor, and a 6V motor!

July 19, 2014

Lorenz Attractor Finished, What Next?

In the past two weeks, I have been busy with programming. First of all, I managed to find myself a part-time programming job, and secondly, I was working on a serial library for both Arduino and Processing. the Processing half of the library went well, but the C++ version for Arduino was excessively complicated. In the end I decided to put the idea on the backburner and finish up my Lorenz attractor program.

Here is the result:
With the added joystick and potentiometer knob, this controller now controls every aspect of the program in the same way as the keyboard and mouse!

What next? Good question. I really do not know, I have several ideas and new electronics to try. Here is a list of possible ideas:

  • Try more fractals! I have a whole book of fractals to try!
  • Try new electronics parts! I have a temperature sensor, a hall effect sensor, a rotary encoder, a rotary switch, remote controls, even a Wii nunchuck! I have yet to try any of the above!
  • Try new microcontrollers/single board computers! I recently bought a Parallax Propeller Quickstart development board and I ordered a BeagleBone Black to try! Eventually I plan to get a Raspberry Pi to add to the computers I've tried!
  • Try to make a roguelike! Roguelikes are text-based RPG games characterized with random dungeons and permadeath. I've always wanted to try one, and I think I've found a library for making them!
  • Try to make cellular automata! Akin to fractals, they can be anything from cool patterns to falling sand games!
If anyone's reading this and wants to see anything of the above, just let me know in the comments!

July 6, 2014

RGB Rainbow + More

Yesterday, I decided to test out my newly-soldered RGB LED. I made a simple animation that cycles through every possible hue. Here is a video:


Today was a rather slow day compared to last week. I did manage to solder one of my 7-segment displays to a circuit board to make it easier to work with. It is still untested, but here are a couple pics:



Besides this, I mostly did some organization of my code. I'm starting to make a large index of every program of mine that I can find. The goal is to make a well-documented programming portfolio to have for the future.

In terms of the Lorenz attractor, I did get some work done on it. The basic program is functionally complete, though I have much to do to make it better. I will save the video of the program for another day as a surprise!

July 5, 2014

Lorenz Attractor: Dependence on Initial Conditions

Fractals have a heavy dependence on initial conditions. That means that if you change anything about the initial conditions, even something so small as changing the millionth decimal place, the resulting motion will take a completely different path than the original.

Here is a video of the Lorenz attractor with three particles (red, white, and blue). They all appear to start at the same point and take the same path. However, it does not take long before the particles diverge and take completely different paths.


Here's the most surprising bit: The initial positions of the particle differ by 0.0000006 units! that's 6 ten-millionths of a unit! This was the smallest change in position I could use with my program without suffering the effects of rounding error.

To make it more clear that the particles are moving in different paths, here is another video with the lines turned off:

More Arduino Sketches and Fractals!

Progress on my Arduino sketches and the Lorenz attractor fractals has been so good this week, I have two videos I have yet to post and even more to make!

Yesterday, I found some time to do some soldering. The board on the left is an RGB (red/green/blue) LED complete with three resistors. The other board is an adapter for a Wii Nunchuck.
I already started trying out the LED today (video will be posted tomorrow), it works well. The nunchuck adapter I probably will not use for a while, I have other things to try out first. 

Next, we have a test of a numeric keypad that I recently bought. I used two Arduino boards in order to try out serial communication between Arduino boards. The first Arduino determines what button was pressed, assigns it a numeric value, and sends said value over serial connection to the second Arduino. The second Arduino then sets the LED to that brightness level.



I also have another video of my Lorenz attractor program. I will explain more in my next post!

July 4, 2014

Yet Another Cool Thing

Recently I found a library called proTablet, which allows a Processing sketch to read information from a graphics tablet like the Bamboo tablets from Wacom. One of the variables you can read is the pressure of the pen pressing down on the tablet.

I decided to send this value over serial connection to my Arduino board. From there, I sent the value to an analog pin with a jumbo LED attached. The result? An LED that gets brighter the harder you press the pen down on the tablet. Here's a video:


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