Category Archives: Uncategorized

Arduino + Reflectance Sensor

This is a specific example of connecting a reflectance sensor from pololu:
to an Arduino Uno.

I’m using this for a sumobot line sensor.

1st get the library from pololu:

Put the individual library folders in your Libraries subdirectory for Arduino.

next, connect wires as follows:
+5v -> vin
gnd -> gnd
A5 -> out

then, open op the arduino app, connect to your board and upload this code, this code is for 2 sensors, it will work fine for 1:

PololuQTRSensorsRC qtr((unsigned char[]) {18,19}, 2, 2000, 255); //declares two line sensors on pins 18 and 19 this corresponds to analog pins 4 and 5

unsigned int sensors[2]; //creates thew variable
//setup is required.
void setup() {
// initialize serial communication:

void loop(){;
//sends the info to serial so you can view it in the serial monitor.
Serial.print(" ");

upload the code to the board.

In the Arduino app goto tools->Serial Monitor. Here you should be able to see the results of the reflectance sensor.

Now in order to code it for a White line you have to determine what value you want it to react to, so give it some tests.

oince you set your linethreshold variable you can start doing comparisons like this:

if (sensors[0] > linethreshold){ stuff to do }

Flot + Pie updates: donut, border labels, hover in IE

I have been using javascript libraries for charting lately. I find it works well wil ajax / jQuery pages very well instead of flash because they share variables and functions.The best Open Source one I could find was Flot: The most obvious thing missing from it is a Pie chart which was added and updated in the forums of the project. The forums can be confusing, the files have been branched changed etc so many times and the thread style of the subject makes it very difficult. so here are the latest files I could gather that include pie, and my updates.

Updates include:

Border Layout for labels: The labels are optionally on the outside of the cart square with lines pointing to the respective slice.

Donut Hole: Optionally set an inner radius for a hollow center.

Hover in IE: IE support for flot requires excanvas: but excanvas does not support a function that makes the hover easy (isPointInPath) so I added a workaround.

I hope this helps, I may make a full project page out of ALL of the flot updates + examples.



Love / Hate of console.log

console.log is the most necessary debug tool for javascript ever, but it only works in FireFox with FireBug. Otherwise it gives you an error, could sabotage all of your other javascript. You could just comment them all out before releasing code. OR you can add a condition around it so that it only shows if it won’t error.

For security reasons you may want to comment out the console.logs anyways, but it doesnt hurt to apply this method to make sure it never produces an error.

if(typeof console.log == ‘function’){ console.log(‘your log string or object here’); }

jQuery CheckTree Update: start expanded or collapsed.

I’m having good success with the jQuery Checktree plugin which can be found here:

I added a config option that allows the tree to start collapsed or expanded. It defaults to the current behavior (Collapsed).

In order to start with the checktree expanded define it like this:

jQuery("div#formMedia .checkTree").checkTree({  
    collapsedarrow: "../collapsed.gif",  
    expandedarrow: "../expanded.gif",  
    blankarrow: "../check0.gif" ,
    collapseOnInit: false

The updated code can be found *here*

Agent Based Systems Development

What used to be my fun side projects has quickly become my job. I’d like to continue that cycle by finding new side projects that are fun and challenging. I also like to find projects that I actually think would be something new and interesting that people would appreciate. An idea came to me recently that brought together a lot of past ideas in a new light. When I did some research on it I discovered that that topic area is called “Multi-Agent Systems” or “Agent Based Systems”

What is it?
Agent based systems have multiple independent entities called agents that can communicate / and cooperate. I was happy to find that there are some applications that exist to do simulations and modeling: and some standards on programming these systems:

The appeal is obvious. This approach is not very well developed in computing and robotics. Communications between systems (agents) are plentiful and always improving. Like with people, multiple systems working together can be much more powerful than thier simple sum.

A new implementation!
All of the multi agent systems modeling apps I found are in Java, I’m starting my project in ActionScript. I plan on extending portions of it to use AIR as well. I like Actionscript due to its natural abilities to communicate and be visual. One of the main focuses of my implementation of the agent based model will be on the monitoring, management, and repair of the complex systems. Even in small Agent implementations that are just for a fancy presentation it’s interesting to see the number agents, their status, type etc.

I won’t type out all of my ideas here. I wanted to just put in a quick note on the subject in case any of my colleagues would be interested in sending me tidbits in this area or following my progress. The new projects will start out at

Creating a plugin / addon / extension for Internet Explorer

I had a need to create an extension to IE. When I did my initial research I couldn’t find anything that seemed to address the subject. Since Internet Explorer is the most commonly used browser on the internet I knew I was doing something wrong. Apparently I didn’t even know the propper terminology to use for what I was doing.

The most basic extension to Internet Explorer is called a “Browser Helper Object” or BHO

just knowing that would have saved me a couple of hours.

A Browser Helper Object is in the form of a .dll that is intended to interact with IE. Other things like toolbars can be built on top of it.

Creating a BHO: anything that can compile a .dll can be used. It’s easiest to find references that are in Visual Studio and C++ or Visual Basic.

Development: The development is deceptively simple once you get started. There are a few basic methods that are required like getSite and setSite. These can both be very quirky so I suggest referring to a tutorial to create these most basic methods: once you have the basics methods setup you have to get yourself acquainted with a new lirary of features know as MSHTML which allows you to interact with IE and the documents it references:

as usual it helps to have code to look at, I suggest browsing the projects at CodeProject, I found many there that were helpful.

There are a few distinct things that a BHO can do that you can’t do easily with anything else (At least for IE).

  1. Create interaction between the desktop applications and the web
  2. Simulate user interaction, that is transparent to sites.
  3. Bypass cross site security restrictions
  4. DOM manipulation on any site.

I only found 1 boook that even mentioned Broowser Helper Objects, and it was very useful. Unfortunately it’s only for VB

Once you have the BHO developed, what ties it to Internet Explorer is that it has to be linked to IE in the registry. The process is spelled out in the tutorial I linked earlier. It’s very easy to see if the connection to IE exists by looking at the “Manage Addons” menu.

I hope that helps launch someone starting the process.