Sunday, July 26, 2015

Display animation on OLED using arduino i2c

A photo posted by Mohesh Mohan (@moheshmohan) on

Hey folks,

So i got this new cheap oled display that i wanted for a long time and its time for us to play with it. So you can find lot of tutorials on the web on how to drive the display but lets just move a step farther, lets do some animation with it.

OLED 0.96" 128X64 from aliexpress
what i have is an OLED 0.96" 128X64 I2C (or IIC) interface, with SSD1306 driver, 3.3/5V compatible.

There are 4 pin on the OLED module, GND, VCC, SCL and SDA. Typically to use I2C on an arduino uno you need to connect it something like this

GND - GND on Arduino Uno
VCC - 5V on Arduino Uno
SCL - A5 on Arduino Uno
SDA - A4 on Arduino Uno

Lets have a look at the fritzing view of the connections

Now how do we drive this thing? Don't worry there is an awesome library for led/lcd displays its called u8glib and you can get it here

Now based on this i have created a simple program to display an animation. You can get the source code here

Basically what i have done is just take 3 bitmap images and play it in a sequence to show the animation. If you look at the source code you can see the arrays in which image information is stored. Now its very easy to convert a bitmap into an array of hex values. you just need the picture editor called gimp

Open the desired image in gimp and save it as ".xbm" format and just open the xbm file in a text editor, you can get the hex values array for the image. Pretty simple :P

Mohesh loves robots :D
You can watch all of this in my video here

Here is the source code for those who don't wanna go to github

Tuesday, July 7, 2015

Now that terminator genisys is out, how about a Terminator T800 Desktop toy - My 3d printing saga

Hi Folks,

If you have read my other posts about my 3d printing saga, you might have guessed that i already built a 3d printer. Sorry to leap forward with this post before completing my build log of the printer but i think this is the right time to post this. Especially now we have the Terminator genisys on theaters.

So that the terminator movies rebooted itself with the new movie genisys in theaters now, i wanted to do something for the amazing T-800 :). I am an avid fan of terminator series, i love the animatronics and graphics used by them.

Then i found a cool 3d model in thingiverse with holes for led in t-800 here. This is an awesome model as it has slots for 5 mm LED's in the eyes and has passage inside head for wires. Awesome.


So I downloaded the model an printed it using white PLA. The print took almost 6+ hours but it turned out to be amazing. See for yourself
T800 Front
T800 side

As you can see the white material does not project the details of the model well, when photographed. This is not what i wanted, i want a realistic one. Then i began studying on painting techniques.

I found that acrylic paint does fine job on plastic, but it needs some kind of primer before it can be applied. So i bought some plastic primer to do that, but it turns out that the primer is highly poisonous and is nasty. I didn't want such a thing, it could be messy :P

So I consulted with few of 3d printing gurus in my facebook friends list, so a good friend of mine pratheesh prakash, who run a robotic company, told that you could use fevicol (Glue for wood) and water mixed in 1:1 ratio. I tried it and it worked perfectly after few tests.

If you watched the movies you obviously know that terminator t-800 played by Arnold Schwarzenegger, has shiny chrome head and bright red glowing eyes. I bought a spray paint can of chrome paint from ebay for INR 150, then set of to paint the head. First i applied the primer as mentioned above and let it dry for an hour or so. I think applied 2 coats of  primer like that.

Then after all drying i painted it with chrome paint. After 2 coats of painting and hours of drying in between. The head looked like this now

T800 painted front view
T800 painted side view

So as you can see its gained lot of details after paint job. Though its not exactly close to metallic perfection on close inspection, this definitely made me happy :D. Note that the paint took really loooooong time to get dry. Also i am no painting expert so i think i applied too much paint at several areas causing loss of some levels of detail.

Now to fix the LEDs, though the eyes are designed to fit 5mm LED, i found it hard to properly seat one inside. So i took a 5mm drill bit and ran through the hole at really really low RPM. This opened up bit more space and i was able to fit in the LED perfectly.

Leds Fitted
Funny Laugh t800
Now that we have all the work done with the head, i wanted a bit more fun than just lighting it up.

At first I wanted it to light the leds in form of nice animation so I decided to control the leds via an arduino nano. Then I thought an arduino has so many pins vacant, so may be I will add something more. Then I found a PIR motion sensor lying there and I decided to add motion detection to the project. So finally It would be a usb powered motion detecting t800 head that blinks led eyes in different patterns, lol thats big description :-) 

Having decided all that, i then printed a case for PIR sensor and arduino nano. Just to keep it clean and sexy :D

I found the PIR case here. And the arduino nano case is this one i slightly modified it. Its easy with scad and the file needed is there in thingiverse.

The following is the fritzing view of the wiring (click to enlarge)

T-800 Usb Powered Desktop toy wiring

Now that everything is done its time for programming. I searched the net to get different type of led blink effects and as of now i have incorporated about 7 blink effects in the code. You can find all the code, schematics in my github repository here ->

Okay now that everything is ready, have a look at the t800 sitting on my office desk on a pc :)

Dont forget to check out the youtube video and please share subscribe, comment like

See ya next time, Happy hacking

Here is the youtube video :)