Thursday, August 23, 2012

Getting the CMPS03 compass to work with the Arduino

Code for testing a digital compass using Arduino UNO

/*
CMPS03 with arduino I2C example

This will display a value of 0 - 359 for a full rotation of the compass.

The SDA line is on analog pin 4 of the arduino and is connected to pin 3 of the CMPS03.
The SCL line is on analog pin 5 of the arduino and is conected to pin 2 of the CMPS03.
Both SDA and SCL are also connected to the +5v via a couple of 1k8 resistors.
A switch to callibrate the CMPS03 can be connected between pin 6 of the CMPS03 and the ground.


*/
#include 

#define address 0x60 //defines address of compass

void setup(){
  Wire.begin(); //conects I2C
  Serial.begin(9600);
}

void loop(){
  byte highByte;
  byte lowByte;
  
   Wire.beginTransmission(address);      //starts communication with cmps03
   Wire.write(2);                         //Sends the register we wish to read
   Wire.endTransmission();

   Wire.requestFrom(address, 2);        //requests high byte
   while(Wire.available() < 2);         //while there is a byte to receive
   highByte = Wire.read();           //reads the byte as an integer
   lowByte = Wire.read();
   int bearing = ((highByte<<8)+lowByte)/10; 
   
   Serial.println(bearing);
   delay(100);
}

Thursday, August 16, 2012

Getting started with Arduino robots

The Arduino microcontroller has finally made robotics work fun. I've worked with other microcontrollers such as RoBoard, Freescale, Parallax, and found them to be more frustrating than fun. The Arduino has changed all that in my case. This shows what I've been able to do with just a few evenings.

In the first evening, I was able to get an Arduino board to drive some LEDs within just a few minutes.


A little more work, an I have motors and servos working. By the third evening, I had my first autonomous robot using one ultrasonic sensor for obstacle avoidance:


I made version 2.0 of my robot, so that I could have more breadboard space, giving me an LCD display and two ultrasonic sensors:


The ultrasonic sensors had to be polled separately so they did not confuse each other. A bigger issue was the the robot no longer turned well. The front wheel does not turn, and the robot was now heavy enough that the front wheel no longer easily skidded sideways, like it did in version 1.0 of my robot.

Yesterday in the mail I got a different wheel I ordered that solves this problem, by having small rollers on the wheel allowing it to slide sideways. So here is version 2.1 of my robot:


I'll be adding a magnetic compass soon, and eventually starting version 3.0 of my robot.

Friday, June 29, 2012

I get in class new student teachers who need an endorsement that they have taken a programming class. Sometimes these students aren't that interested in programming, they don't see how it will apply to them.

My lesson: "If you learn to program, and put your lessons out on the web you will reach more students than you ever would in the classroom." And I practice what I preach. I've been working with my on-line book ProgramArcadeGames.com a lot this summer. Traffic has increased, thanks mostly to reddit.com. Here is a graph of unique visitors per day:

Even more important, according to Google Analytics, about half of the visits are returning visitors. During the month of June I've had over 1,300 visits where more than ten minutes was spent browsing the site. About 500 of those spent more than twenty minutes on the site.

I am reaching more students on-line than I am in the classroom.

Wednesday, June 27, 2012

Learning to Program Arcade Games

I recently purchased http://ProgramArcadeGames.com for my on-line book on how to program. A couple posts to reddit.com have brought in a lot of traffic. I'm hopeful that the new website address will help bring in search traffic.

Tuesday, January 31, 2012

Educational Assessment

College tuition is soaring five times faster faster than inflation, while 45 percent of students did not demonstrate any improvement in learning. For-profit schools are sucking up federal dollars, some of them getting over ninety percent of their revenue from federal money, while graduating only 22 percent of the students that start. The current solution to this problem that is being pushed to this problem: educational standards and assessment. It is, however, a dangerous path to follow.

Where does this come from? I'll blame Iowa's own Edwards Deming. Edwards Deming helped manufacturing industry by attempting to apply a bit of science to manufacturing. Measure the quality of what you create. Try something new. See if it helps.

The U.S. didn't like him, so he went to Japan. Guess what? Engineering your manufacturing process using evidenced-based changes did help! So now it seems like everything is made in Japan and other Asian countries. The key was to create a continuous cycle of evidence-based improvement.

Now, society wants to apply this to teaching as well.

Good teachers will naturally go through this process of assessment. They will continue to work on their class and find ways to improve it. They find out what other teachers are doing. Good teachers learn how to judge the personality of the students they work with, and learn techniques for working those students.

This process of continuing improvement is why good teachers often write their own books, and keep editing them to make them better. They create their own lesson plans and improve them year after year. But the process isn't perfect.

The problem in applying this to teaching? The impossibility of creating a common benchmark that can be used to evaluate the effectiveness of each teacher. Education is about humans. Since we are working with so many different humans, there are too many variables. Variables such as:
  • Different teachers have different styles. (The variety between teachers works well to keep students interested.)
  • Students aren't all the same, and they respond to different techniques.
  • Some students are capable of excelling in certain subject areas. Other students just move slower.
A continuous process of improvement assumes a controllable set of variables. Unfortunately this is not a situation that exists inside of academia. Particularly once the scope starts extending beyond the range of a single school, or even a single teacher.

At an individual or small-group level this continuous improvement may still be possible. Once the process expands to a larger group, it is too easy to get caught up in the paperwork and 'process.' People pay attention to the paperwork being required, and ignore the real goal of providing evidence-based improvements. A process that worked for one group may not work for more people.

This article does a wonderful job of explaining why this is bad:
Big Macs vs. The Naked Chef

(Seriously, go back and read that article. It is 10 times better than this one and you are wasting your time if you continue reading without having read that other article. Plus it has the word "naked" in the title, so it has to be good.)

Yes, that article was about software development. But the theory is the same in education.

What I hate about educational 'standards' is that it works to bring up poor performing people to the average, while bringing down high-performing teachers. We are left with an uninteresting homogeneous soup at the end.

Do we want our schools to be McDonalds? Do we want our students to be Big Macs?

Monday, May 16, 2011

Creating movies from still images

I've been trying several ways to create movies from a set of still images. I find commercial packages to be too expensive for this simple task. Blender does a good job, but I prefer the simplicity (and script-ability) of a command-line tool. At first I tried MEncoder, but I could never find options that would produce a decent result. There were always too many compression artifacts.

What I've settled on is ffmpeg. I use the following command:

ffmpeg -r 30 -b 1800kb -i image%d.jpg movie.avi

The %d is the number of the picture. This seems to produce a decent balance between file size and output quality.

Wednesday, October 27, 2010

Creating a brick wall with Blender 2.54

I have been wanting to create a brick wall with Blender. I found this tutorial to be very helpful. It works well if the camera is not very close to the wall. It is fast and easy to put together.

It is also possible to put together a brick wall with an array modifier. But what really inspired me was the example script for creating castle walls available here. That script did not work for the current Blender 2.54 Beta version. So I thought I would work on creating my own script.

Here is a development version of my script. I thought I would post it here so that others looking for Blender 2.54 Beta scripting examples could find it

 import bpy 
 
 row_count = 8        # Number of rows
 bricks_per_row = 15  # Number of bricks in each row
 cube_x = .25         # Length of each brick
 cube_y = .25         # Width of wall
 cube_z = .125        # Height of each brick
 row_gap = .01        # Gap between each row
 brick_gap = .01      # Gap between each brick
 
 # Calculated values
 offset_amount = cube_x/2    # Staggers bricks
 rescaling_factor_x=cube_x/2 # Used to size the brick
 rescaling_factor_y=cube_y/2
 rescaling_factor_z=cube_z/2
 
 # Loop for each row
 for row in range(row_count):
     # Calculate if we stagger this row
     offset = row % 2 * offset_amount
     # Loop for each brick
     for index in range(bricks_per_row):
         # Add the brick
         bpy.ops.mesh.primitive_cube_add(
             location=(index*(cube_x+brick_gap)+offset, 
             0, 
             row *(cube_z + row_gap)))
         # Resize the brick
         bpy.ops.transform.resize(
             value=(rescaling_factor_x,
             rescaling_factor_y,
             rescaling_factor_z))
         # Bevel the brick
         bpy.ops.object.modifier_add(type='BEVEL')