Hardware

Arduino Heaven

I believe coding is like giving a human superpowers. The possibilities of what you can create are endless. So yes being a coder is amazing and you get to do a lot of things, but we must never forget our hardware side! Arduino helps facilitate this process by bridging software and hardware together in a magnificent fashion. Do you want hands on building where you can solder pieces together, wire them together and watch yourself build something from the ground up? Do you want to create a crazy program with easily maintained, readable, efficient and beautiful code? Then come no further. With Arduino, you can do both. You can build hands on projects and code them just the way you want. This brings technology to a whole new level, well at least in my book.

All my life, the only aspect of technology I knew was the software side. I thought that for hardware, you had to go to a good college and major in electrical engineering just to be able to build things. This was actually part of the reason why I decided to major in computer science in the first place. However, as it turns out, I was completely wrong. With arduino, you can indulge in all these crazy projects all from the comfort of your home. Not to mention that the arduino community is huge. The coolest page I have found so far that showcases awesome projects built by others who documented the whole process and even included source code is defintely instructables. There are a whole bunch of different awesome projects you can build yourself using their guides, and even build upon and make it better. The whole point is to build something really cool that someone someday might find interesting and want to further its development. This process of taking and giving is what makes building with arduino so much fun.

After doing some research and doing mini sample projects that comes with the arduino kit, I was able to get a hang of how it works which helped when I was looking over some projects on instructables. It’s super straight forward and pretty easy to follow if you have some programming background in languages such as C and C++ since the majority of guides and tutorials are mostly based on explaining the hardware aspect of the project. If you want to extend projects, you will definitely have to familiarize yourself with the arduino syntax.

After I became comfortable with arduino, it was finally time to start my own project! I wanted to make a custom 3D printed lamp, so I explored thingiverse until I found a design I would like to build upon (No need to re-invent the wheel now is there?) and I downloaded the files into tinkercad, a 3D web interface for designing and creating cool things, and started messing around with it.

Here is the lamp base with a simple arduino case on the side to hold the arduino when connected to the lamp.

Screen Shot 2015-08-11 at 11.48.00 PM

Here are some little window frames I made to hold and support the placement of plexiglass on top to make it transparent for the lights to shine through.

Screen Shot 2015-08-11 at 11.49.00 PM

Using a 3D printer, I was able to print out my lamp. Below is a little video of the printing process:

After a few days of printing, my sister broke it….

IMG_20150513_180640:nopm:

This time instead of 3D Printing a lamp, I decided to be a little bit more creative and use a nice little wooden box which I spray painted black. After having the object in which I would like my lights to go in, it was time to start building! After finished the wiring, which surprisingly didn’t take me that long, it was finally time to start coding.

First I had to create a way to talk to my neopixels

 #define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

After having a way to communicate with my neopixels, I had to create some colors in 5:6:4 RGB hex format. I was able to find a nice little program online that converted normal hex values to 5:6:4 hex values. I then used the output of that program to create different shades of colors in my code:

/** BLUE SHADES
* Navy – 0,0,128 => 0x0010
* Blue – 0,0,255 => 0x001F
* Deep Sky Blue – 0,191,255 => 0x05FF
* Light Sky Blue – 145,206,250 => 0x967F
* Cyan – 0,255,255 => 0x07FF
* Turquiose – 64,224,208 => 0x471A
*/

uint16_t shadesOfBlue[7] = {
  0x0010,
  0x001F,
  0x05FF,
  0x967F,
  0x07FF,
  0x471A
};

After having some shades of colors, I was able to call them using a simple for loop. Below is an example of how to turn all of the neopixels on with a Navy Blue color:

for(int i=0;i<60;i++) {
    pixels.setPixelColor(i, pixels.Color(0,0,128));
    pixels.show(); // This sends the updated pixel color to the hardware.
  }

To turn them off, it’s pretty much the same process. Just make sure you set the RGB values to 0:

for(int i=0;i<60;i++) {
    pixels.setPixelColor(i, pixels.Color(0,0,0));
    pixels.show(); // This sends the updated pixel color to the hardware.
  }

Now the neopixels are set up. It’s time to create a grid system on the touch shield to function as a remote control for the neopixels. The grid system I had in mind was fairly system. Have some equally sized boxes, each representing a different function or color which when pressed would turn the neopixels on with that color. To make this easier, I declared some constants to work with the width and size of each box as well as how many rows of boxes can fit on the screen. I also created a delay constant to pause from running any more code for a bit so you can see the neopixels changing one by one instead of all almost instantaneously.

//First Row
  for(int i = 0; i < ROWS; i++) {
    tft.fillRect(BOXSIZE*i, 0, BOXSIZE, BOXSIZE, shadesOfBlue[i]);//xywh
    delay(delayval);
  }

With just a little bit more code, I was able to make it function just how I wanted. And with that, I bring you my completed project – Novo Arduro

20150512_195419

touchshield

20150516_162958

If you want to see the whole process documented with more pictures and videos, check out my novo aduro post on my class blog. If you are looking for the complete source code, then be sure to check out the project on my github. I also have some instructions and links to guides on how to get started.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s