Thursday, November 29, 2018

Helping a STEM student Arduino homework

A few weeks ago I responded on LinkedIn to someone who was looking for someone Arduino savvy. Turned out to be someone looking for help for her daughter that had trouble with a STEM course assignment.

Now I don’t usually do these kind of help. Most of the time it’s lazy students looking for someone to do their homework for them for free of 10$... I have been burned before.

But this time it was different. First it was the parent asking and after a few exchange I could feel that they were willing to put in the effort.

The task at hand was pretty easy. The student needed to reproduce an Instructable project based on an Arduino Uno, a 16x4 LCD and an analog joystick. The Instructable project was this one:

I first discovered that they and bought the wrong LCD and did not have the joystick part. I help them source it and during the time they waited for the parts I went on to build it myself. The hardware assembly was pretty straightforward and I had all the parts. Here is the Fritzing diagram:

Next I went on on compiling and uploading the code provided in the Instructable article. It did not work. The code was supposed to wait for you to select a level, but it would instead go straight to the game. Joystick did not work to control the snake… Then when I had that “Oh great, what did I get myself into” moment.

After a 30-40m adding debug print to the serial console and analyzing the code I figured out that the bugs in the code and just fixed it quickly. At least now the code was doing what it was basically designed to do. There are still some bugs in it where the snake jumps sideways, but the plan was never to fix it, just to get it working.

I did adjust the code writing style to match what I use so that it can be somewhat more readable. I did not add any comments or change the code structure.

You can download the fixed source code here:

Now the parent and her daughter got the parts but the male header is not soldered on the LCD and they have yet to find someone to do it. I’ll update this post with issues they went through as I help them out.

Friday, November 16, 2018

Adding shadow to images from the command-line (macos/linux)

When doing documentation, adding a shadow to images or screen grab makes the document come aline and helps break text from images.

For example the following image:

Is pretty "normal" and does not stand-out. However with a single command you can turn it into this:

You will need the ImageMagick package installed:

On macOS if you have brew installed it's as simple as running: brew install imagemagick

Then to add a shadow as shown above you simply have to run:

my_image="pi.png" ; cp ${my_image} ${my_image}_original ; convert ${my_image} \( -clone 0 -background gray -shadow 80x3+10+10 \) \( -clone 0 -background gray -shadow 80x3-5-5 \) -reverse -background none -layers merge +repage ${my_image}

Just change my_image="pi.png" to reflact the filename of the image to shich you want to add the shadow to. The above command will create a file with _original which is your original unmodified image.

Wednesday, November 14, 2018

Montreal Advanced Design and Manufacturing Expo 2018

So I attended the the Montreal Advanced Design and Manufacturing Expo at Palais des congrès today.

Was not expecting much, attended out of curiosity. It was really aimed more at the factory automation and packaging business but managed to get to know a couple of sensors manufacturers as well as a Fab (PCB assembly) house that accepts prototype level quantities.

But what I was most disappointed about was the Palais des congrès wifi... On the expo floor I could not connect to the free wifi network from my iPhone of MacBook. It would simply not give me any IP address... The only wifi network that was working was a paid one, so I used one of my 5h of free Fido internet and tethered...

On the floor outside the expo area I managed to connect to the free wifi and get the portal page, but could not get pass it:

So I went over to one of the VanHoutte but it's wifi was locked and I was sitting down with my laptop so did not feel like going to the counter to ask for the password and leave my stuff unattended.

Luckily there was a TimHorton just in front and I was able to connect from there, but my PPTP (yeah I know) would not work...

Integer to it's binary string representation in C

My oldest son is studying mathematics and programming in college and wrote me asking for a way to convert an integer to it's binary repr...