All parts are assembled and it’s ready to be programmed

All the mechanicals parts and the control boards are now assembled and wired up together. All functions have been tested separately. Now come the time to do some programming. But before I will show you what I’ve already done in my next posts.

Because some pins of the Arduino have a special function, like interrupt, the connections on the proto will be useful to connect thinks to the right pins when I will start programming. I’ll probably use my previous (modified yesterday) multitasking script to be able to control all things at virtually the same time.

Glowing Marquee prototype assembled and wired up

Put your image up in the air

My goal is to use an image and output it to the marquee. I really don’t want to build matrix characters one by one. I mostly want to create anti-aliased characters or graphics. How? By making the leds blink more or less time. That will make the glow-in-the-dark stripe illuminate more when the led lit more longer. So, for now, I code a test program in PHP, a familiar language for me, to read the image and output the result data I need to give to the Arduino microcontroler.

There is the idea of code :

	This script display a black and white graphic
	constructed in a html table
	based on the readed jpg image.

// Declare the image file to read.
$file = "test.jpg";
// Read the jpg file and create an image in memory.
$image = imagecreatefromjpeg($file);
// Get the size of the image.
$width = imagesx($image);
$height = imagesy($image);

print "<table><tr>";
// Read one row of the image at a time.
for ($y=0; $y < $height; $y++) {
	// Read one column of the image at a time.
	for ($x=0; $x < $width; $x++) {
		// Get the index of a pixel.
		$pix_index = imagecolorat($image,$x,$y);
		// Get the decimal RGB color of this pixel.
		$A = imagecolorsforindex($image,$pix_index);
		// Convert this color to gray scale.
		$col = ($A['red'] + $A['green'] + $A['blue'] ) / 3;
		// Convert this color to hex.
		$col = dechex($col);
		print "<td style=\"width:10px;height:10px;background-color:#{$col}{$col}{$col}\">&nbsp;</td>";
print "</tr></table>";

Glowing marquee

Inspired by the Record Player Display projet, I start doing one of my own. A glowing stripe marquee, using an old scanner ripped off. The objective is to learn how stepper motors works, optic switch and resume my experience with logic chips like the 74HC595 shift register. Globally, everything is relatively simple and it’s just a matter of seeking the right information over the internet, and a bit of thinking. The current video is presenting my first test, without the mechanical part. Just the leds and the glowing vinyl stripe moved manually. The last week, I solder the leds and the shift register on an permanent circuit board. It will be fixed on the scanner soon. The optic limit switch works and it will be used to know the reset position of the scanner. The next step will be to assemble the circuit board for the step motor driver. I use a L293D. So happy viewing. You will understand why I certainly make some mistake in my writing.

Step one, step two, motor on!

When I was young, I had two unipolar (don’t know that detail since this week) stepper motors. My pleasure was to connect them together and when I spinned one, the other performed nearly the same rotation. It was a great pleasure to play with. But I finally make one (bipolar) really work today. Yeah! I work hard to understand the motor I got, the MITSUMI M42SP-4. When I look over the Net to find some specs, it’s never what my motor look like. So I guest a four wires bipolar, and I tried it on 5v, safely. Something append, but not correctly. Any bad connections with the L293D? I think not. I found, after a while, that my problem was the Arduino stepper library. I don’t know if I was doing something wrong but it’s look like the stepper function always stimulate both coils at the same time. So I coded an ugly function to recreate the four steps needed, and Bingo! This will make my projet go further.

Parallel programming

After working hard on basic looping kind of parallel programming, I got a hint on Plumbing library. It’s based on OCCAM-pi language and it sound really promising. I read as much as I can found about it, it’s look like it will facilitate the emergence of great programs for the Arduino. As is it now, not much information is available. I’ll wait for more within the next months. Actually i’m very busy on a business project so, i’m not so eager for news about them, but i’ll keep looking for more documentation.

Multitasking/multithreading in C on Arduino

Doing multitasking/multithreading on Arduino has an advantage, it’s give the possibility to read multiple captors, blink led and start a motor at virtually the same time. This is done by cycling rapidly (faster as the Arduino can) witting all the functions. I made up this code to execute many functions in the default cycling loop function on the Arduino. In the sample, the starting functions are hard coded, but The program offer the advantage of starting and stopping functions at run time. In a more complex program I’m doing it by adding a serial communication ability to the code, so I can call only the functions I need.

// By - 2009-10-17.
// 2010-05-11: Better and lighter.

// Define a function pointer and initialize to NULL.
typedef void (*FunctionPointer) ();

// Declare looping actions function names, declared lower.
FunctionPointer xActions[] = {loopActionA,loopActionB,loopActionC};
// Define actions status flags. Set to 1 to auto execute a start.
int xActionsFlags[] = {0,0,0}; 

int xActionsCount = sizeof(xActions);

void xActionTrigger(int id=0, int action=0) {
  // The id represent it's position in the flags array.
  // Action 1 = executed, 0 not.
  xActionsFlags[id] = action;


void loopActionA() {
        // Do something...

void loopActionB() {
	// Do something...

void loopActionC() {
	// Do something...

// Exectute all loop functions.
void xDoActions() {
	// Execute all looped function.
	for(unsigned int j=0; j < xActionsCount; j++) {
		if( xActionsFlags[j] == 1 ) { // Execute the action if.
			xActions[j](); // Call the related loop action.

void setup() {
        xActionTrigger(0,1); // First action.
        xActionTrigger(2,1); // Third action.

void loop() {