Universal Angle Camera Arm

I’ve been thinking about shooting some time-lapses of projects and I didn’t want to have a giant tripod on the desk and have to move it and set it up every time.

An arm from a desk lamp or microphone should provide plenty of movement and viewing angles on the desk and could be folded out of the way. 

The problem is That while a microphone or lamp do not care about how they are rotated, the camera does. If I mount the camera straight to the arm, I can get the camera pointing at the desk from almost every angle, but in most of those angles the camera would be upside down.

What I need to make this work is to be able to rotate the camera without moving the arm.

What I came up with is a circular camera mount and a clamp that goes over it. The camera can rotate freely in the clamp while being captive inside of it, allowing me to level the frame while not worrying about the camera falling off.

Fortunately, tripod screws are common 1/4″, so a generic short one did the job nicely. I left enough opening in the clamp so that I could turn the screw without taking the inner part out.

In order to mount the clamp to the arm, I drilled some holes in a piece of angled aluminium to fit the original rotating mount and the clamp.The printed part was fitted with 5mmX5mm M3 knurled nuts that were installed using a soldering iron.

Done! a simple solution and it works. Now I can get great footage from every angle.

I left the wires from the original lamp and i’ll use them to power an LED ring later and maybe charge the camera.

The files for printing are available for free on Thingiverse.


Water Cooling a GTX 1080ti

I bought a GTX 1080ti Founders Edition and I’m not happy with the cooling on it. The core runs at 84 degC under load and the blower on the card is very loud if I crank it up to help the cooling (by default, the fan stays at 50% regardless of the load or temps).
These temps aren’t a problem for average use, but I plan to overclock the card and it will definitely get hotter and might start thermal throttling.


I thought about buying an air-cooling solution, as I already have good airflow and can make use of it, but I found an Antec H950 pro all-in-one CPU water cooler that someone was giving away on Facebook, So I decided to turn it into a hybrid.

The guy that was giving away the AIO said it’s 4 years old, it sat for a year without use and that he doesn’t know whether it works or not. What could go wrong?!


Assessing The Damage

First, I gave it power (for a few seconds to not damage anything if something’s wrong) to check that it’s not completely dead – it’s not. It makes the right sounds, the fan is spinning and the LED in the water block seems to work. Hooray! free water cooling!

Next, I opened the block and the pump to see their condition. The pump looks very clean inside and the seals seem fine. The block, on the other hand, has some blue crust blocking the fins. It doesn’t seem to be corrosion or anything like that. The liquid that was in there had a blue tint as well, so I think it was the liquid degrading and clogging the block as it acted like a filter.
All the blue stuff came off pretty easily, I washed everything in tap water and then gave everything an alcohol bath. It seems in very good condition.

Then, I decided I will replace the existing tubes with new ones as I don’t know if this thing had any leaks during it’s life and there was some odd residue on the block’s ports that I suspect came from the blue-ish liquid inside.

Card Disassembly And Fitment

The Founders Edition has a heat sink on the core that is separated from the rest of the cooling plate. This means that if you have a water block that will fit the hole in the plate, you can keep the plate and the blower and not have to mess around with VRM cooling or void your warranty (The warranty sticker is on a screw on the other side of the card).


Unfortunately, my block doesn’t fit. It has a wide and flat bottom surface, where some blocks have an extruded part that gives the block some more height and clearance. Moreover, my block is meant for a CPU so the mounting holes are way off.
This means I’m either enlarging the hole in the cooling plate of the card to accommodate the wider and lower water block or pulling the plate off the card completely and replacing it with something else.
I went with the latter, as I wanted to keep the stock cooler stock so that I could put it back on and return to the original state, If I ever want to.


Making the block fit

As I mentioned, my water block is meant to be mounted on a CPU, so the holes don’t align with the holes on the graphics card.
The easy way to make it fit is to buy an adapter like the NZXT Kraken G10, but that’s cheating. We’re going to go the maker way.

Fortunately, the water block itself, without the mounting bracket, does not cover the holes on the card. This means that I can use the holes to mount a custom bracket.


What I came up with is a 3D printed bracket that will push down on the block and keep it in place while allowing the illuminated center to show.

The file for printing the bracket can be found on Thingiverse.

Cooling A Graphics Card

It’s pretty obvious that the core needs the most cooling on the card, but there are more parts that need to be cooled to keep the card happy and to allow me to overclock.

here is a photo of the card and the parts that need cooling highlighted with red rectangles:



An easy way to tell which parts need cooling without using the internet is to see which parts have thermal pads on them conducting to the cooling plate.

In order to cool the memory and VRM, I have two types of heat sinks that I will cut to size. One with short fins for the memory that doesn’t need a lot of cooling and one with long fins for the toasty VRMs.
Since the different types of components have different heights, I can’t just cut a piece of heat sink that will cover everything (or I’ll have to route channels in it’s bottom for clearance, and that’s not easy). Instead, I cut strips of heat sinks to fit the different components separately.
I also made sure to align the fins with the airflow of my case, since I’m not planning on putting a dedicated fan on there.

The original thermal pads were full of dust and were falling apart so I replaced all of them with fresh thermal adhesive tape, as they will not be screwed to the PCB. later we’ll see that it wasn’t enough.

Rebuilding The Loop And Initial Testing

Refilling the loop was a little bit tricky because there is no reservoir to fill and allow air to escape.
What I did was make a temporary reservoir from an open jar and put it between the pump’s inlet and the radiator, meaning there’s a hose coming from the pump and a hose coming from the radiator, sitting in the jar that’s full of liquid. The tricky part is converting this into a short connection between the pump and radiator once the loop is full, without spilling the water in the loop.
All the other hoses were pretty straight forward to install. The connectors on all the components are simple ones that just press inside the hose (with zip-ties for security).

I filled the loop with straight distilled water. No additives or colors yet.

To fill the loop I had to suck air out of the radiator outlet until water went in and out of the pump, then connect power and quickly put the hose back into the jar. This is because this type of pump is not self-priming, meaning it can’t suck air to pull water from the jar, it has to have water inside it before it’s powered up.

After the loop was full and all the air was removed (by rotating and flipping the block and radiator to allow the air at the high spots above the hose holes to escape), I let it run for a few minutes to make sure that there are no major leaks, no residue from the old liquid and that the loop itself is working.

The test was a success.

I pinched the radiator hose where I wanted to cut it and shut the pump down. Then I cut the hose and in one motion pulled the hose from the pump inlet and pushed the one I had pinched on to the pump instead of it.
I ended up with a little air bubble, but it quickly found its place in the top part of the radiator, never to be pulled into the loop again.

Another short test and I installed the block on the card.


Mounting In The Case And Real World Testing

There are a few ways I could mount the radiator. I initially wanted the radiator on an exhaust fan, blowing the hot air outside, but I only have one fan that fit the bill, and it is too close to the CPU cooler to mount the radiator inside the case. I could mount the radiator on the outside of the case with the hoses running through the dedicated holes in the case, but that would mean that I have to take the loop apart in order to take it out and put it in. Not ideal.

Eventually, I settled for a front intake fan. This way, the radiator will be hidden and I wouldn’t have to take everything apart whenever I want to swap components or maintain something. The only theoretical problem is that the air that is supposed to cool the CPU and MoBo is hotter.

I knew mounting everything in the case wouldn’t be trivial. I have an Antec 900 (gen 1) which has plenty of room in the front, but the drive cages and the front covers that are attached to them only go in from the outside. This means that I have to get the card itself in from the front of the case.
Fortunately, The front covers can be mounted to the case without the drive cages (normally, the front covers are attached to the fan mounts which are mounted to the drive cages, which mount to the case itself).
I mounted the fan and fan mount to the radiator by drilling through the screw holes in the fan mount and mounting the fan straight to the radiator with the fan mount sandwiched in between. The front covers went on top.


2 Minutes after installing the card and one of the heat sinks fell. The adhesive isn’t strong enough to keep the biggest heat sink in place and touching anything on the card risks more heat sinks falling. I’m not powering the card like this, I need something to secure the heat sinks in place.
As a temporary solution, because I’ve been gaming with my “old” GTX 1070 and I’m missing the performance of the GTX 1080ti, I took a piece of 100x100x0.5mm aluminium and some foam, drilled holes according to the ones on the card and put it on top of the heat sinks.
This will restrict airflow somewhat, but it should be enough.

It’s time to pray. Pray that I didn’t kill the card during the weeks it sat disassembled waiting for items to arrive in the mail and all the times it was taken in and out of the anti-static bag for measurement and fitment testing.

And… It works! The card is fine, the loop is working and we are getting good temps for now so we know the block is mounted correctly. Time for some real tests.

I started Aida64 on a GPU only stress test. After about 30 mins I could see the core did not go above 59 degC, being most of the time around 55 with some peaks. That’s a big improvement. I let it run a while longer and the results didn’t change.
In long gaming sessions I saw the same effect, peaking at 60 degC.

That’s plenty of headroom for overclocking.

Ideas For Improvement And Upgrades

Aesthetically, there’s a lot that can be done. I can make a better looking top plate to hold the heat sinks in place, preferably something with holes to allow air to pass from different directions.

Also, the controller inside the block is acting pretty strange, it makes the RPM of the fan fluctuate regardless of the load or temps, this wouldn’t bother me if the fan didn’t make revving sounds like it’s at a car show.
I tried downloading the Antec software and connecting the block to a USB port to try and manually control it, but it didn’t help.
I’m not sure if there’s something wrong with the controller or if that’s how it’s supposed to act, but I figured I don’t really need the controller anyway. The way I installed the radiator, I want the fan to work at moderately low RPM all the time to provide airflow for the CPU cooler even when the GPU is idle. The thermistor or thermocouple (not sure what they have in there) in the block is nice, but also unnecessary and the GRB LED can be controlled in countless other ways.

Removing the controller brings a few benefits, like not having 3 ugly cables coming out of the block and going to 3 different places (power from the MoBo, USB on the MoBo, power to the fan and pump).
I might as well replace the fan to a more quiet one that will be controlled by the MoBo.

I could also 3D print some cool structure in translucent filament and mount it on top of the block so it’s illuminated by the LED.

I may drill holes in the heat sinks and put thermocouples in there to monitor memory and VRM temps and make sure they are sufficiently cooled.

Upload gcode files automatically from Simplify3D to OctoPrint


Some slicers, like Slic3r, have a built-in feature that allows you to send gcode files directly to OctoPrint’s queue without saving and uploading manually. I wanted this feature in Simplify3D.

Someone must have done this already, right?

Kinda. there are a few solutions I found, but they have some disadvantages:
cURL – using cURL to send a POST request to OctoPrint’s REST API via the additional terminal commands for post processing in Simplify3D. This works, but it has a security flaw. A pretty big one – Simplify3D includes the post processing command inside the Gcode file, and the command for cURL contains the unique and secret API key for your OctoPrint server.
This means that ANYONE who has access to the interface (let’s say you opened a port in the router and made it accessible from anywhere) can download files in the queue WITHOUT LOGIN, open them, read the API key and take full control over your printer.
Not good.

The content of a Gcode file sent with cURL

scp – what about copying straight to the machine? well, yes, it works. We are not using the API so no key is required and if you set up ssh keys, you wont need to enter your username and password.
The problem with this is that we are moving files behind OctoPrint without talking to the application, this means that in order to see our file in the queue and print them, we must refresh the webpage.
Not what I’m looking for.

A better solution

From the other examples we learn that we can’t have the API-key in the command and that we must talk to the server (i.e. use the API). This brings one thing to mind – a script!

After some googling and learning a bit about REST and python, I wrote this simple script :

import requests
import sys
requests.post('', files={'file': open(sys.argv[1], 'rb')}, headers={'Host': '', 'X-Api-Key': 'XXXXXXXXXXX'})

The “local” in the url can be changed to “sdcard” in order to save the files on the SD card.
In order to use the script for your setup, replace the IP with your server’s IP and the API-Key with the one for your server (can be found in OctoPrint’s settings under API).

After testing that the script works on its own, it was time to insert it to the post-processing box in Simplify3D.


Note that because I put the script in the Simplify3D folder, the program needed to be run as administrator to run the script (took me a while to figure that one out). You can put it anywhere else and not have this problem.

We can see that there’s no key in the post processing command, let’s see if that’s the same in the file:

The content of a Gcode file sent with python script


Additional features

Once you realize that you can run arbitrary scripts after the file saves, you can do pretty much anything. The REST API allows you to fully control the printer and local commands work fine. I haven’t found any use for other functionalities at this point, but I saw some people who wanted the file to be removed from the computer once uploaded or maybe start the print when the file uploads or run a special Gcode sequence. Not a problem, a quick look at the documentation and you’ll find commands for anything in the interface and a lot more.

3D Printer Lead Screw Upgrade

I built my 3D printer more than a year ago and I think it’s time for an upgrade.

This upgrade was long due and delayed because of lack of time (I worked full time in the summer) and the crawling pace in which the local postage service here works, but enough excuses – let the fun begin!

This upgrade will concentrate on the Z axis movement only, and the replacement of the threaded rods with proper lead screws.

Lead Screw? But Why?

After a year of printing, it can clearly be seen that threaded rods are not meant for this kind of application. The rod itself is not straight (which is not that big of a deal because there are straight rods keeping the movement straight), it squeaks pretty loudly during movement and its threads get full of black goo that consists of dust, oil and metal shavings from the friction with the nut.

A threaded rod is meant to be tightened with a nut and not move, the whole principal of its operation is based on friction – a thing we don’t really want in a moving mechanism.
A lead screw is much more rigid, it’s very hard so it doesn’t bend, it has a very smooth surface and its shape is specifically designed for moving inside a nut.

Made from scratch

I searched for a premade model so I wouldn’t have to model everything from scratch, but with all the different variations and sub-models of the Prusa i3, I couldn’t find one that I was sure would fit without further alterations. Eventually, I decided to design them myself and share for everyone with a similar printer to mine.
I had some big plans and special designs for this project, but It would take a lot of time and I couldn’t stand the threaded rods any more, so I decided to take the current design and improve on it. After the printer is functional with the threaded rods installed, I could take my time and experiment.
This project took two days total over the weekend, including modeling, printing and installing.

To keep the nut in place, I embedded M3 knurl nuts in holes in the plastic about 0.5 mm smaller in diameter than the outside of the nuts. The nuts are inserted by heating them with a soldering iron and pushing them in. A screw helps keep the nut straight while it’s inserted.
The linear bearings are held in place by the plastic itself.

At first, I thought I could get away with replacing only the X axis mounts, but I didn’t account for the lead screw’s center that had to move to make room for the big nut. eventually (after disassembling the printer, swapping the mounts, reassembling and realizing the mistake) I remodeled the mounts, printed them again and reassembled everything.

The old top bracket only supported the straight rod, the threaded rod’s top was floating, which didn’t help with it not being straight.
I improved on the design by including support for the new lead screw, which barely needs it thanks to it’s rigidity.
Instead of letting the lead screw move inside a hole in the plastic, I included bearings that hold the lead screw securely in place while letting it rotate freely.

The bottom brackets are basically the same, I just had to move the straight rod’s hole further out to follow the center dictated by the X axis carriage and the bigger lead screw nut.

All parts were printed in blue PLA @ 0.2 mm layer height and 200 degrees C with no support and no heated bed.
All models are available for Free download on Thinginverse.


The lead screw and threaded rod have different thread counts (the amount of turns per length unit) so the steps per millimeter value for the Z axis needs to be changed in the firmware. This is easily done by simply moving the Z axis 100 mm (direction doesn’t matter), measuring the actual movement and multiplying the current steps per millimeter value by the actual movement measured divided by 100 (watch your units). Repeat this process a few times, each time gets you closer until you reach the accuracy wanted.
Note that the error will be more apparent with longer movements. If you move your axis 1 mm and measure you might not see the error. A 1% error would translate to 0.01 mm with a 1 mm movement (which is something my analog caliper can’t measure), but with a 100 mm movement it would be much clearer at 1 mm.


That’s it. All done. No more squeaking Z axis and wobbly rods. I don’t expect a real improvement in printing quality, although that would be nice, but an improvement in the printing experience.

Final Thoughts

I’ve had some comments about losing resolution with lead screws because of the lower thread count, so lets see if that’s true (spoiler – it’s not):
The threaded rod I had measured at about 1 mm per turn (if I turn it inside a nut once, it will move 1 mm through the nut) and the lead screw measures at around 7.5 mm.
This means that my lead screw is 7.5 times faster than my threaded rod. If I want them to move the same distance, I need to turn the lead screw 7.5 times less than the threaded rod.
If I had a continuously rotating motor, I could, theoretically, have the same resolution (infinite) but the motors used in my printer are stepper motors, these motors move in steps and not continuously. My motors take 200 steps to make a full turn, this is the maximum resolution we can reach (well, there’s microstepping but the idea is the same, there still is a step to be made that determines the maximum resolution and amount of error to be expected).
With 200 steps per turn and 1 mm per turn, we get 200 steps per millimeter. That’s 0.005 mm per step. That’s the smallest increment in length we can make without microstepping.
At 7.5 mm per turn we get 0.0375 mm per step. While this is a larger number, the smallest increment you would expect to make while printing is still even larger. So what does this mean?
This means that the Maximum resolution your axle can reach will go down, but because the actual maximum resolution a 3D printer can reach is even lower, this doesn’t matter.
The maximum resolution I reached with my printer is 0.1 mm layer height and I don’t print at that resolution often. Even if I try to reach 0.05 mm, the lead screw would still be enough. Moreover, my firmware has microstepping enabled so the maximum resolution is much higher (microstepping can go down to 1/32 or even 1/64 of a step) and if I really want to go crazy, I could get geared motors to reduce the ratio to 1:14, 1:30 or even slower.

3D Printed Filament Rack

20150716_212129 When I first started out with 3D printing, I had like one or two spools of filament. I would mount one on the printer’s built-in spool holder and the other would lay around somewhere. As I started experimenting with different materials and colors, I accumulated quite a few spools that would lay on top of each other, looking like a leaning tower of filament. Every time I wanted to replace filament, I had to play filament Jenga, pulling the one I wanted from the stack without making the tower collapse on top of my expensive speakers.

Before. Notice the spools onthe top right stacked on top of each other
Notice the spools onthe top right stacked on top of each other

It looked bad, it was dangerous and uncomfortable, it was time for change. The first thing that came to my mind was “Someone must have had this problem before me. There’s probably a model ready for download on Thingiverse”, but all I found were single spool holders or more complex racks with spools mounted on bearings or on the wall. I wanted something simple, so I made one myself.

After. All the spools are nicely
All the spools are nicely racked and the needed one is fed to the printer directly

I had a spare metal broomstick laying around that was perfect for the job. It’s light but strong enough to carry the weight and it’s cheap enough so I wouldn’t care re-purposing it. I designed the model in SketchUp, I wanted to make it quick and keep it simple so I didn’t need any super-advanced tools. The model is just a clamp on triangular legs. The clamp attaches to the broomstick, obviously, and the triangular legs prevent the whole thing from tipping over. I added some braces inside the legs to provide structural integrity. I wanted both sides to be identical so I could just model one side and print it twice (instead of having to model a different piece for each side).

There are some guidelines and limitations that I had to follow in order to make this function as I want: The diameter of the broomstick is ~21.5mm. In order for the clamp to work, it had to be slightly smaller that value in it’s closed position and slightly larger when it’s open. The clamp needs to be high enough for the spools to clear the bottom, taking into consideration that the top of the spool’s hole sits on top of the broomstick rather than them being coaxial (I might add an attachment to the spools to make them coaxial and maybe reduce friction) The base needs to be wide enough for the rack to be stable and not tip over by the force of the extruder and external accidental forces. I’m not too concerned about friction and the force applied bu the extruder’s pull because the broomstick I chose is laminated and the spools slide on it very easily. The gap of the clamp needs to be big enough to work but not too bit or the plastic might break or its layers separate. The clamp levers need to be long enough to accommodate the screw head and nut and thick enough so they don’t break under pressure.

Print settings: Material: red PLA
Temperature: 190 deg C
Layer height: 0.3 mm
Infill: 10%
Print Time: ~80 mins per side
Slicing and interfacing program: Simplify3D
Printer type: Prusa i3

The model is available on Thingiverse along with the original file so people could make changes if they want.

Bluetooth Controlled, 3D Printed Sims Plumbob Costume

For the last Purim festivities I made a Sims Plumbob that’s controlled via an android application through Bluetooth to simulate the Sim mood.
In this article I’ll show you what I’ve done and why so you can make one yourself.

The Plumbob

The Plumbob itself was 3D printed. The shape is very simple and it can be modeled very easily, It’s just two hollow hexagonal pyramids glued to each other.
Lazy me didn’t want to start modeling so I found a pre-made model on thingiverse. The shape was perfect and I had the perfect material for the job – a translucent green PLA filament. I chose this material because I wanted to put lights inside that would illuminate the Plumbob in different colors, the material was translucent enough for colors to penetrate and be seen at night and it was green so it would be recognizable in the day, when the lights are not very visible.
The downloaded model has a stem on one side, but it’s not hollow (I needed a stem to mount the Plumbob and it needed to be hollow for electrical wires to go through it). I needed to drill through the stem, which is not an easy task, I ended up breaking it and using another method to secure the Plumbob to its mount.

The Plumbob was printed out of Translucent Green PLA at 190 degrees C. 0.3mm layer height and 100% infill. The print took about 3 hours for each half.

The Mount
I needed a way to mount the Plumbob a few inches from my head, I wanted it to look at night as if it was floating, like in the game. I figured a hair bow with a rod on top painted black could do the trick.
I needed a wide bow for stability, a narrow or thin one would just fall from the weight and movement. I thought about 3D printing a custom mount but I didn’t have enough time to measure, model and make one so I went to the nearest store and tried some bows on.
I didn’t find a wide enough bow, but I found a bow that looked like three bows connected at both ends, it was flexible enough so I can pull them apart to make the whole structure wide enough. Moreover, when I pulled them apart the entire structure was stiffer, less flexible, which is exactly what I needed.
On top of the bow I put a piece of tin I cut to shape with some tin sheers, the tin provides a strong base for the stem and will hold the stretched bow parts in place. I used two part Epoxy glue for all connections.
The stem is an aluminium tube cut to length with the ends split and bent to follow the contour of the hexagon pyramid to be attached to it on one side, and the tin base plate on the other.

Before gluing the Plumbob half to the stem, I spray painted the whole thing black.

I used RGB LEDs for lighting and a 5V Arduino pro mini for control. The Arduino supports about 40mA of current draw from each pin and the LEDs are common Anode and draw about 20mA per color (I used 6 LEDs, that’s 120mA total current for each color of all LEDs on full brightness), so I had to use 2N3906 transistors to switch power to the LEDs (I could have connected each Cathode of each of the LEDs to another pin in the Arduino to avoid the current problem, but the Arduino doesn’t have enough PWM pins and that would require me to modify the code).
To save space on the circuit board, I shortened the Cathode leads of the LEDs and 150Ohm resistors and soldered them together inline.
To make life easier, I made a jig by fixing a 5mm LED bezel with vice grips, this made soldering very easy.

I used a HC-05 Bluetooth module for communication and a U1V11F5 5V step-up converter so I could power the whole thing with 2xAAA batteries.

The Bluetooth module operates at a 3.3V logic level while the Arduino operates at 5V, the arduino would understand the 3.3V from the Bluetooth module fine, but 5V to the Rx pin of the module could fry it. for this I connected the module’s Rx pin to the Arduino’s Tx pin via a voltage divider (a dedicated logic level converter circuit would have been ideal but I didn’t have one nor did I have time to wait for one to arrive).

The circuit had to be mounted to a post made of aluminium tube, so I had to insulate the tube to prevent shorts. The circuit was held in place with zip ties, the LEDs were wrapped around and hot glued in place so that they point in different directions to illuminate the whole shape (in retrospect, I could have used shorter leads for the LEDs).
The aluminium tube was held in place with hot glue and then secured with Epoxy.
The battery holder was mounted on the stem for lack of a better place to put it. I thought about putting it in my pocket with wires running inside my shirt, but they proved to be too long and the resistance was too high so the Arduino would reset when the current draw was high and the voltage dropped.
I needed the batteries on the outside because the power switch was on the holder and I wanted to be able to change batteries. If I had more time I would have probably installed a rechargeable li-po battery inside the plumbob with a small switch and a charging port poking from the side.

Untitled Sketch_bb

The Code
I didn’t have time to write an android application, so I found a free one on the Play Store that fit my needs exactly. There are a lot of applications that do similar things and much more, but this one had a friendly interface and did just what I wanted.
In the description of the app there’s a link to a free example code (and a full code for purchase). I used the free example and modified it to fit my setup.
I also had to use the Software Serial library because, for some reason, the Bluetooth module refused to work with the Arduino’s Serial pins. I used pins 10 and 11 for serial communication with the module (this also allowed me to upload sketches to the Arduino without disconnecting the module).

//pins for the LEDs:
const int redPin = 6;
const int greenPin = 9;
const int bluePin = 5;

#define REDPIN 9
#define GREENPIN 6
#define BLUEPIN 5

#define FADESPEED 5

char serialByte = '0';
#include <SoftwareSerial.h>
SoftwareSerial BTserial(10, 11); // RX | TX

void setup() {
// initialize serial:

// make the pins outputs:
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);

Serial.print("Arduino control RGB LEDs Connected OK ( Sent From Arduinno Board )");

void loop() {

// if there's any serial available, read it:
while (BTserial.available()) {
 // look for the next valid integer in the incoming serial stream:
 int red = BTserial.parseInt();
 // do it again:
 int green = BTserial.parseInt();
 // do it again:
 int blue = BTserial.parseInt();

for(i=0; i<3; i++)
 int waste = BTserial.parseInt(); //the app sends data for two sets of LEDs, we don't need this
 // look for the newline. That's the end of your
 // sentence:
 if (BTserial.read() == '\n') {
   // constrain the values to 0 - 255 and invert
   // if you're using a common-cathode LED, just use "constrain(color, 0, 255);"
   // This is for COMMON ANODE
   //red = 255 - constrain(red, 0, 255);
   //green = 255 - constrain(green, 0, 255);
   //blue = 255 - constrain(blue, 0, 255);
   red = constrain(red, 0, 255);
   green = constrain(green, 0, 255);
   blue = constrain(blue, 0, 255);
   // fade the red, green, and blue legs of the LED:
   analogWrite(redPin, red);
   analogWrite(greenPin, green);
   analogWrite(bluePin, blue);

   // print the three numbers in one string as hexadecimal:
    //BTserial.print("Data Response : ");
   //BTserial.print(red, HEX);
   //BTserial.print(green, HEX);
   //BTserial.println(blue, HEX);
   //Serial.print(" "+green);
   //Serial.println(" "+blue);


Additional Thoughts
After the awesome experience with OpenBCI and EEG technology in my previous project, I thought about making this a truly interactive and realistic Plumbob that’ll work in real life. The OpenBCI could sample your brain waves and through machine-learning detect your emotion, this can be then translated into triggers for the Arduino to change the color of the LEDs according to your REAL mood! but that’s a whole other project that will take much more time.

BrainiHack 2015 – Blue GSD with Brain Controlled Labyrinth Game

This weekend (13-14.3) two of my friends (Gal Weinstock and Maxim Altshul) and I participated in the BrainiHack 2015 event hosted at the AutoDesk offices in Israel.
BrainiHack is a neuroscience themed Hack-A-Thon, where makers come to compete in a day-and-a-half long neuroscience-related project building marathon.

My group is called Blue GSD, we are two Communication Systems Engineering students and a Computer Science student. we came with absolutely no background in Neuroscience and tried to make something awesome. We brought an arsenal of tools, electronic components and a home-built 3D Printer.
We ended up winning the special OpenBCI prize for the best project in the open source category. The prize was an OpenBCI Starter Kit valued at 500USD.

Our project is a Labyrinth game controlled via brain waves (EEG). We are using OpenBCI, an arduino based open source bio-sensing microcontroller, It’s brilliant and with some initial assistance from Conor, one of the founders of OpenBCI, it’s really easy to work with.

The Labyrinth
The game itself was entirely 3D printed, it’s movement is provided via two micro servo motors controlled with an Arduino Uno.
The mechanism consists of three nested frames that are anchored in different places to achieve two degrees of freedom – roll and pitch.
We had no time for strong glue and I didn’t want to make any permanent connections (I’m designing on the fly so a lot can go wrong, and some did) so my design had to be zip tie friendly, the motors and motor arms are all attached with zip ties to the frames. The hinges are M3x16 screws and nuts with some washers to keep the frames in place relative to each other and press them onto the motor.
In the end we noticed we didn’t have enough clearance under the device for the frames to move all the way and we had no time to print another outer frame, so we had to make lifters for the legs which actually worked out perfectly.
Models for all 3D printed parts can be downloaded free at Thingiverse.com

As mentioned before, OpenBCI is an open source EEG device (and more, but that’s not relevant right now, I might explore more of it’s capabilities in the future) which was handed out to whoever wanted to use it.
With OpenBCI we could attach electrodes wherever we wanted (as opposed to some of the other fixed position alternatives), that way we could experiment with different methods and brain waves and choose the ones that work for us.
Conor from OpenBCI was kind enough to give us a little guidance and showed us another project done with OpenBCI, a five-person controlled shark balloon by chip, from which we learnt a lot about the system.
In addition to all of its advantages, it’s Wireless! It includes an RFduino that transmits the data to a dedicated USB dongle that plugs into the computer.

Brain Waves
We wanted to explore more than one type of brain waves. The shark balloon project was based purely on Alpha waves, a 7.5-12.5Hz wave our brain produces in the Occipital Lobe when we close our eyes and relax, that’s neat but we wanted more. Alpha waves are very easy to detect but there’s only one type of Alpha wave per person, this means that in order to control 2 axis we would need 4 people or 2 if we use direction toggling (more on that next).
After some research we found out about SSVEP (Steady State Visually Evoked Potential), a phenomenon where the brain produces a frequency (and/or harmonies of a frequency) that matches the frequency that excites the retina. This means that if we look at a light that blinks at a constant frequency, the brain will produce the same frequency. After some experimentation, we found that the range 5Hz-20Hz was easiest to detect and that 16Hz was far enough from the Alpha waves so they don’t get mixed up.
By combining Alpha and SSVEP we have 2 types of waves we can control and anticipate, which gives us the ability to control the game with just one person.

Controlling the Game
The problem with this technology is that it’s very slow, it’s not real-time by any standard. It may take a few seconds for the wave to generate and be detected while the Labyrinth game requires finesse and delicate movements to balance the ball, this is impossible with 2 or 3 second delay between reaction and actual movement of the platform.
To overcome this challenge we decided to simplify the game, instead of continuous control of the position of the platform, each axis would only be fully tilted to one side or the other, for this to work we created a super-simple maze layout, no holes, no balancing, just walls with straight angles.
As mentioned, we wanted to control the whole thing with one person and we had two different signals we could extract. Left-right position toggle was controlled via Alpha wave and up-down position toggle was controlled via SSVEP.


Data Analysis and Translation
OpenBCI provides a neat GUI that allows you to visually see the data and analyse it more easily. The interface provides time-domain and frequency-domain (FFT) graphs as well as a map of the head with electrode activity.
Once the data is captured with OpenBCI, it is transferred to the computer for analysis, the computer runs a Processing program that computes the Fourier Transform of the signal over a defined interval of time, filters the spectrum to look at relevant frequencies and finds the most powerful frequency in the range. If the peaked frequency is the one we are looking for, a command is sent to an Arduino board via serial port. The Arduino then controls the servos according to the command received.
In our project, we were looking for peaks at around 10Hz (Alpha) and 16Hz (SSVEP) and had to ignore the very high peak at 50Hz that is caused by the AC power frequency here in Israel.

Screenshot from 2015-03-13 13_27_35

The code running on the computer is a modified version of the shark baloon’s code. Since they already figured out the Alpha wave capturing and translation, we had to modify it for one person (they used 5) and add the SSVEP frequency capturing. The shark balloon code was taken and modified from another project (which modified the original code from OpenBCI) so it’s already a little messy and we probably made it messier (with a day and a half to get the whole thing to work we had no time to waste on making it pretty).
The code running on the Arduino is fairly simple, just a loop polling input and controlling the servos. We made the servo movement slow and continuous so that the ball doesn’t jump around.
The code will be uploaded to GitHub in a few days.

Special thanks to Conor over at OpenBCI for helping us and introducing us to the technology.