Skip navigation
1 2 3 4 Previous Next

Arduino Projects

48 posts

 

Just in time for Halloween and Fall, a pumpkin… But not just an ordinary pumpkin. This one will stand out of all the other pumpkins sitting on people's porches…. Just sitting there. This pumpkin is about to fly away. Yes, a UFO pumpkin with lights. Ideal for the front porch of a house you want to catch people's eye as they pass by. If Christmas lights and decorations weren’t enough, we are bringing the decorative house lights earlier into the season. Now you can annoy your neighbors with flashing lights before Christmas.

 

Project by sections:

For this project, I carved a pumpkin using a UFO stencil and wrapped it in a 16.4ft WS2812B, individually addressable, LED strip controlled by an Arduino UNO and powered by a 5V 10A power supply.  A 3rd of the LED strip is inside the pumpkin, another 3rd is wrapped around the stem, and the last is wrapped around the outside. The strip is fed through the top lid with a rectangular hole. This 16.4ft strip has a total of 150 Individually addressable LEDs.I created my own lighting sequences and put them one after the other for a UFO-like show.

 

BOM:

1x Arduino UNO R3

1x 16.4ft WS2812B Waterproof LED Strip

1x 5V 10A AC to DC Power Supply

1x 5V 500mA AC to DC Power Supply for Arduino

1x Large Pumpkin

1x Pumpkin Carving Kit

 

Schematic and design:

 

Operation:

The code starts off in the main loop and calls each lighting function. The timing and number of cycles for each lighting sequence is passed into the function by the parameters entered in the function call. For example, color of LED section and timing. The first lighting sequence is called “spaceShipStart” which shows the inside blink green 8 times and goes solid, then the outside flashes a quick orange/pumpkin color. The inside and outside increase in brightness until max. Once at max, the top turns on to green to represent the stem. The second sequence keeps the top lit as the green stem, inside as purple and the outside shoots orange around the pumpkin. The third sequence is a rainbow, where the whole strip cycles through every color at different places on the strip. The fourth is called a cascade where 1 LED is lit and moves position very fast. This looks like a 1 color wrapping around the pumpkin till it goes inside and makes a faint blinking. The last sequences, blink the top, outside, and inside as their respective colors, this turns into a fade in and out, where the brightness cycles from minimum to maximum. The “spaceShipStart” then starts again being on a loop.      

 

Code:

The code was developed using the Adafruit NeoPixel library. This library lets you control the color, brightness, and which pixels are on or off. This library has some examples of lighting sequences to help get started. The code splits up the leds by section, for each of the lighting sequences, the LEDs for the outside, inside, and top get set. The programmer sets which lights are ON and what color, then is displayed to the strip using leds.show(). The sections of the strip are addressed by knowing what LED is lit in each section. There are 150 LEDs, the inside of the pumpkin had 39 LEDs from the end of the strip, so to address the colors and sequences of the inside of the pumpkin you would start from the end of the strip in your for loop and assign the color of the lights from the end decrementing the variable until you’ve reached your last inside LED from the beginning, since we are going backwards in assignment. So the for loop starts at 150 and decrements until it reaches LED 111, this means the LEDs 111 through 150, represent the inside of the pumpkin.

 

Difficulties:

Assigning the brightness was difficult because the brightness function provided by the library was a global brightness. Which means that the whole strip always has the same brightness. So if you want to make one part of the strip a different brightness from another at the same time, you have to come up with a more clever way to do it then using the library’s function, “leds.setbrightness()” before leds.show(). 

 

Other uses of the system:

This strip can be used in a variety of different applications, after this project, I already have some ideas to use this on something else. Bar lighting, room lighting, custom Christmas lights, you can tell your neighbors you did it yourself when they ask where you bought that from. The individually addressable lights make a good indicator of something. You could strand this up on your garage wall and make a parking indicator reflect where your car is with the individual LEDs. There are a lot of possibilities.    

 

If I had more money/time:

More lighting sequences, remote/trip sensor to start, sunlight sensor to turn on at night. The LED strip was waterproof, but my Arduino was not, so a waterproof case for the power and control electronics would make it last longer outside.  

 

Oddities and observations:

The LED strip came with mounting brackets that made it very convenient to attach to the pumpkin in the back. Also, the camera couldn’t keep up with adjusting the brightness for the LEDs at night ─ so you might see some effect from that. At night it was very bright and definitely will catch the attention of people walking by. As you can see in the zoomed picture below, how bright it is.

 

Pumpkin Making:

 

{gallery} Making the pumpkin

 

 

 

Thanks for reading!

http://twitter.com/Cabe_Atwell

 

#ShareTheScare this Halloween

Visit our Halloween space and find out how to win one of two Cel Robox 3D Printers. There are two ways to win:

Share your Project and Win
#ShareTheScare Competition
The Ben Heck Show Episodes

 

Disclaimer: I’m an engineer, not a pro film maker. Be advised.

Disclaimer: I’m an engineer, not a pro film maker. Be advised.

 

 

This was a project in the making some years ago… See more about it here.

 

In this evening’s project, I want to evoke one of the most primal fears… eyes in the darkness.

 

It’s rooted in a real scary threat, some sort of wild animal. Rat, dog, flying squirrel, wolverine… whatever is the wild thing from where you’re from. Usually those eyes in the weeds/darkness are following by slow backing away or full blown running.

 

Just imagine, you’re alone in a forest. The evening is washing through the trees, dragging darkness with it. Before you know it, your vision shortens to half, maybe less of a distance in front of you. Light is almost gone. But there… somewhere between the foliage.. a pair of eyes appear. Maybe more. Maybe a whole lot more. The creatures of the forest are closing in. At least… that is the effect I was going for.

 

In this project, we are going to start out with one pair of eyes. I’ll show you how to add blinking for more realism. For the ambitious, I will show how to chain a bunch of eyes together for a greater effect.

 

 

The project by sections:

 

This project could easily be done without a microcontroller. Even the “blinking.” But, for a greater amount of control, I decided to use an Arduino Nano. It’s more about future proofing than anything, more this in the “If I had more time and money” section below.

 

The “eyes” are simply a pair of LEDs. I chose red for a classic evil monster look. I also use orange for a closer to an animal’s eyes in the darkness. However, any eye color is cool, I suppose. Perhaps blue for a “Game of Thrones” zombie.

 

I added a Light Dependent Resistor (LDR), or photoresistor, as a sensor for the Arduino Nano. I wanted to detect the ambient light conditions and turn on the “eyes” only when it is dark enough. Nothing ruins scary eyes like the daylight! As light disappears, the resistance of the LDR shoots through the roof, for those who are wondering. This is how the light level is detected, based on a resistance value.

 

In the circuit, I added a few potentiometers to adjust various aspects of the scary eyes. First, the brightness of the eyes – real eyes in the dark don’t look like a pair of headlights. The frequency of the blinking effect is also adjustable.

 

BOM:

1x Arduino Nano

1x Full-size breadboard

2x Small breadboards

1x Photoresistor

1x 10kOhm resistor

2x 1K Ohm resistor

4x 220 Ohm resistor

3x Potentiometer 100kOhm (I used these types, but you could use others)

2x NPN transistors (PN2222)

2 pairs of LEDs (Red)

Project wires

 

Schematic and design:

 

 

It is this simple. The complexity comes in the code.

 

This is the actual build. I strung an extra pair of eyes off of one of the mini breadboards - I stuffed the LEDs into a yarn ball. Also pictured is the 9V power supply I used to power it.

 

 

Code:

 

If you connect the Arduino to a PC, I put in an option to output serial data.

In the Scary Eyes project, I output the states of the three potentiometers. I label them as well, Threshold, Brightness level, and Blink duration.

 

 

Suggestions on the build:

 

You do not need to use breadboards for your “eyes.” You could just make a harness to string out the eyes where you see fit. Just run them back to the Arduino Nano.

 

I thought this system would be used indoors. Rain would be a huge issue to running it outside. Here are some suggestions about if you want to use this outside.

 

- First and foremost, run the system off of a battery to make it portable. The types you charge cell phones with would work.

- Put the Arduino Nano and its support components inside a water-tight enclosure with the battery.

- Run the cables outside the enclosure for the LEDs. This may require drilling and hot glue to seal the and potential leak points you create.

- Waterproofing the LEDs is the hard part. You could use a similar principle as the Nano’s enclosure. You could also put the LED inside a clear enclosure.

 

 

Other uses of the system:

 

- This is a prefect system to put inside the carved pumpkins. It will even turn on in the dark!

- You could also use them as eyes for the pumpkin too.

- Or, how about an overly complex nightlight?

 

Oddities and observations:

 

I found no real change in brightness when running off of a 5V USB connection. I didn’t string more than 3 sets of eyes though.

 

If I had more money/time:

 

- Originally, I wanted to add sound that would play as people approach the eyes. However, adding that would have cost too much in terms of logistics for the devices.

- My big plan for this was to make 100 pairs of eyes that would turn on in waves as people went through a wooded path. First a few, then a lot. Coupled with sound, that would be terrifying…. I thought.

 

Cabe

http://twitter.com/Cabe_Atwell

 

#ShareTheScare this Halloween

Visit our Halloween space and find out how to win one of two Cel Robox 3D Printers. There are two ways to win:

Share your Project and Win
#ShareTheScare Competition
The Ben Heck Show Episodes

 

 

Disclaimer: I’m an engineer, not a pro film maker. Be advised.

Disclaimer: I’m an engineer, not a pro film maker. Be advised.

 

 

Tonight’s Halloween project is another effect as old as time… Scary Shadows.

 

Shadows are obscure, raise suspicion, we can only imagine what creates them. The fear of the unknown is one of the basic, most natural fears. Even when a shadow is clearly defined, we still have a hard time gathering what it is exactly. Depending on the light source, the shadow of an object can be distorted and disorienting.

 

A shadow can be a monster, an entity, or just someone creeping up behind you. Young and old can get scared of a shadow.

 

To create a simple shadow casting project, I went about creating an Arduino stepper motor control system. Simply put, the stepper motor will move cutouts into a light source, casting shadows, for a few different effects.

 

 

The project by sections:

 

The concept is simple, cast shadows and control their movement.

 

To accomplish this, I used a stepper motor to turn a special 3D printed hub holding paper cutouts of various “monster” shapes. Placing a strong light source behind the cutouts will make a shadow on a surface.

 

I used a 1000lm LED flashlight for the light source. However, I found that removing the lens from the end of the flashlight produced a wider spread of light. With the cutout close to the LED in the flashlight, the shadows were large and distorted at times. Which was a cool effect.

 

Since I was controlling a stepper, I could control the direction and speed fairly easily. So, I had three modes of movement.

 

- Constant, clockwise

- Constant, counter clockwise

- Bounce between the two directions with a single button push. Like hitting limits.

 

A single potentiometer on the breadboard controlled the speed. Although I was in single-step mode, meaning the stepper moved one step per pulse, it was fairly smooth across most speeds.

 

 

BOM:

 

1x Arduino Nano

1x Full-size breadboard

1x DRV8825 stepper driver

1x Low current Stepper motor

2x Momentary Push buttons

1x Potentiometer 100kOhm (I used these types, but you could use others)

1x 9V power supply. (I used a switching power supply from an old device.)

Project wires

1x Light source of choice. I used an LED flashlight

 

Schematic and design:

 

Not pictured is the 5V USB connection you also need on the Arduino Nano.

 

The actual build. The stepper motor bub is a custom 3D printed part. I could have just used tape and the paper.

 

 

 

 

Code:

 

If you connect the Arduino to a PC, I put in an option to output serial data.

In the Scary Shadow project, it will display the direction data.

 

Difficulties:

 

-The paper cutouts were a pain to make a use, to be honest.

 

 

Other uses of the system:

 

- This is a prefect system to put inside the carved pumpkins. It will even turn on in the dark!

- You could also use them as eyes for the pumpkin too.

- Or, how about an overly complex nightlight?

 

 

If I had more money/time:

 

- First and foremost… 3D print the silhouettes as opposed to paper cutouts.

- I would like to explore digital shadow casting. Using an opaque screen, I could “turn on” pixels that could block light, hypothetically. I could animate the shadows! Now, that would be awesome.

- Sound is always good to add to effects.

- I wanted to create an effect of a crowd rushing behind someone. But, I think I would need more elaborate shadow casting apparatus. Perhaps a linear stage along with this rotary option.

- Add micro-stepping for a smoother turn

 

 

Oddities and observations:

 

- At the slowest speeds, there was a lot of vibration created by the single stepping.

- At high speeds, the stepper would slip. Which simply means that it was getting pulse faster than it could react. There is a maximum speed.

 

Cabe

http://twitter.com/Cabe_Atwell

Arduino-Based Automatic Guitar Tuner

 

One of the most important things when playing guitar is making sure that the instrument is in tune. Even the best guitar player will not sound any good with an out-of-tune guitar. Tuning guitars by hand using a standard tuner has always been common, but an automatic tuner makes things much easier, and more fun! This Arduino-based project will tune your guitar for you.

Here is a video showing the project in action: https://www.mathworks.com/videos/automatic-guitar-tuner-using-simulink-and-arduino-1501787185047.html

Overview

 

The figure above shows an overview of the automatic guitar tuner.

  • The push button is used to select the string to tune
  • A six-LED display is used to indicate which string has been selected
  • The gripper connected to the motor is used to turn the tuning peg until the string is in tune.

The inputs and outputs are controlled by the four circuits mentioned above: a digital input circuit for the push button, an analog audio input circuit for the guitar, a digital output circuit for the LED display, and a motor-driving circuit for the tuning peg gripper. These four circuits interact with an Arduino Due, which is running an algorithm that was developed using Simulink.

Digital Input and Output Circuits

 

The circuit for the push button is a simple switch with a pull-down resistor. The LED display circuit involves 6 LEDs and a current-limiting resistor. The circuits are connected to the Arduino as shown in the diagram below.

 

Audio Input Circuit

The guitar is connected to the tuner via a standard guitar cable. The end of a guitar cable has two connections, called the tip and the sleeve. One end of the cable will be connected to an input jack, which has leads for the tip and the sleeve. Wires are soldered onto these leads to connect the tip and the sleeve to the audio input circuit.

 

The analog input pin ‘A0’ on the Arduino is used to read the audio signal coming from the guitar. The Arduino Due reads voltages between 0 V and 3.3 V. The signal coming from the guitar, however, is very low in amplitude and oscillates around 0 V, meaning it contains some negative voltages that the Arduino cannot read. To fix this, the input circuit needs to amplify the signal and add a DC offset. The circuit also needs to provide a low pass filter to eliminate high-frequency components from the signal. Any sampled signal should not contain frequencies above half of the sampling rate. Since the tuner samples the audio at a rate of 5 kHz, my circuit eliminates frequencies above 2.5 kHz. The circuit is shown below.

A TL972 op amp is recommended for this circuit. It is a very-low-noise, rail-to-rail amplifier that can operate at very low supply voltages.

Motorized Tuning Peg Gripper

 

I controlled the motorized tuning peg gripper using three digital output pins from the Arduino connected to an L293D H-bridge chip. This chip allows us to turn the motor in either direction or stop the motor based on the states of these three pins. One of the pins is called the enable pin, and the motor will only turn when the enable pin is set to high. The other two pins determine the direction of the motor. I connected the circuit as shown below.

I couldn’t use just any DC motor for this project. I needed a geared motor with a low speed and a high torque. The motor I used has a speed of 6 RPM and a maximum torque of 613 oz-in. It has a voltage range of 3-12 V, and so I used a 9 V battery as the power source.

On the shaft of the motor, I assembled a simple gripping mechanism using a clamp hub, four screws, and some tape.

Software

I used Simulink and its support package for Arduino to develop the algorithm for the tuner. Simulink is a block-diagram environment used for developing algorithms and modeling dynamic systems. The support package allows me to read from and write to pins on the Arduino using Simulink blocks. Using the software’s external mode capabilities, I can simulate an algorithm on the Arduino with automatic code generation and tune parameters while the simulation is running, without having to recompile any code. I can then deploy the algorithm to the hardware for standalone execution. The model I created is shown below.

External mode allows the use of scope blocks to monitor portions of the algorithm while it is running on the hardware. This is especially useful to monitor the digital input from the button and the analog input from the guitar. From the button scope, we can see that the input changes from 0 to 1 when the button is pressed.

I want this change from 0 to 1 to trigger a change in the selected string. This is known as a rising trigger. I created a Stateflow chart called “Select String” that has six states, one for each string, and changes from one state to the next based on this rising trigger input. Here is a more detailed look at the Stateflow chart.

Upon entry to each state, the LED pin for the corresponding string is set to high. Upon exiting each state, the pin is set to low. I chose the low E string, the lowest of the six strings, as my default. When I first power the tuner on, it will start in this default state.

There are seven outputs on the Stateflow chart: one for the LED for each of the six strings, and one called “periodRange,” which I will discuss later. The six LED outputs go straight to Arduino digital output blocks to power the appropriate LED on or off.

Now let’s look at the audio processing portion of the model. The guitar signal comes in through the analog input block. I set the sample time of the block to be 0.0002 seconds for a 5-kHz sampling rate. When I played the guitar and opened the audio scope block, I was able to see a waveform like the one below.

The scope block helped me tune the potentiometer in the audio circuit to change the gain of the input. The gain should be set as high as possible without the waveform’s peak reaching the maximum value of 1023. This will allow for the most precise reading of the signal.

When the guitar is not played, the input signal should be a flat line somewhere between 500 and 700. In my case, it was around 550. It is important to know this value because the tuner should process the audio only when there is a note being played. I chose a value of 575, just above this flat line, to be my threshold. The audio will be processed only when the signal is above this threshold value. Since Simulink allows me to tune parameters while a simulation is running, I was easily able to set my threshold value.

When a single note is played on a guitar, the waveform generated is periodic. The period of the waveform corresponds to a certain musical pitch. The tuning algorithm estimates the pitch of the string by determining the period of the waveform. I wrote a MATLAB function that performs this pitch estimation, and included it in my Simulink model using the MATLAB function block. To determine whether the string is in tune, the MATLAB function needs an input indicating what range of periods is considered in tune for each string. This is the output “periodRange” from the Stateflow chart. The function determines whether the pitch of the string is too high, too low, or in tune based on the period range, and generates outputs for the motor accordingly.

The outputs of the MATLAB function are the three pins that control the motor. These outputs go straight to Arduino digital output blocks.

Once I ensured everything was just right with my algorithm, I was able deploy it to the hardware so that it could run standalone, without being connected to the PC and independent of Simulink.

Now I can tune my guitar automatically!

All the necessary files for this project are available here:

https://www.mathworks.com/matlabcentral/fileexchange/63697-automatic-guitar-tuner-using-simulink-and-arduino

Overview

The figure above shows an overview of the automatic guitar tuner.

  • The push button is used to select the string to tune
  • A six-LED display is used to indicate which string has been selected
  • The gripper connected to the motor is used to turn the tuning peg until the string is in tune.

The inputs and outputs are controlled by the four circuits mentioned above: a digital input circuit for the push button, an analog audio input circuit for the guitar, a digital output circuit for the LED display, and a motor-driving circuit for the tuning peg gripper. These four circuits interact with an Arduino Due, which is running an algorithm that was developed using Simulink.

Digital Input and Output Circuits

The circuit for the push button is a simple switch with a pull-down resistor. The LED display circuit involves 6 LEDs and a current-limiting resistor. I connected these circuits to the Arduino as shown in the diagram below.

Audio Input Circuit

The guitar is connected to the tuner via a standard guitar cable. The end of a guitar cable has two connections, called the tip and the sleeve. One end of the cable will be connected to an input jack, which has leads for the tip and the sleeve. I soldered wires onto these leads to connect the tip and the sleeve to the audio input circuit.

I used the analog input pin ‘A0’ on the Arduino to read the audio signal coming from the guitar. The Arduino Due reads voltages between 0 V and 3.3 V. The signal coming from the guitar, however, is very low in amplitude and oscillates around 0 V, meaning it contains some negative voltages that the Arduino cannot read. To fix this, the input circuit needs to amplify the signal and add a DC offset. The circuit also needs to provide a low pass filter to eliminate high-frequency components from the signal. Any sampled signal should not contain frequencies above half of the sampling rate. Since the tuner samples the audio at a rate of 5 kHz, my circuit eliminates frequencies above 2.5 kHz. I assembled the circuit as shown below.

I would recommend using a TL972 op amp for this circuit. It is a very-low-noise, rail-to-rail amplifier that can operate at very low supply voltages.

Motorized Tuning Peg Gripper

I controlled the motorized tuning peg gripper using three digital output pins from the Arduino connected to an L293D H-bridge chip. This chip allows us to turn the motor in either direction or stop the motor based on the states of these three pins. One of the pins is called the enable pin, and the motor will only turn when the enable pin is set to high. The other two pins determine the direction of the motor. I connected the circuit as shown below.

I couldn’t use just any DC motor for this project. I needed a geared motor with a low speed and a high torque. The motor I used has a speed of 6 RPM and a maximum torque of 613 oz-in. It has a voltage range of 3-12 V, and so I used a 9 V battery as the power source.

On the shaft of the motor, I assembled a simple gripping mechanism using a clamp hub, four screws, and some tape.

Software

I used Simulink and its support package for Arduino to develop the algorithm for the tuner. Simulink is a block-diagram environment used for developing algorithms and modeling dynamic systems. The support package allows me to read from and write to pins on the Arduino using Simulink blocks. Using the software’s external mode capabilities, I can simulate an algorithm on the Arduino with automatic code generation and tune parameters while the simulation is running, without having to recompile any code. I can then deploy the algorithm to the hardware for standalone execution. The model I created is shown below.

External mode allows the use of scope blocks to monitor portions of the algorithm while it is running on the hardware. This is especially useful to monitor the digital input from the button and the analog input from the guitar. From the button scope, we can see that the input changes from 0 to 1 when the button is pressed.

I want this change from 0 to 1 to trigger a change in the selected string. This is known as a rising trigger. I created a Stateflow chart called “Select String” that has six states, one for each string, and changes from one state to the next based on this rising trigger input. Here is a more detailed look at the Stateflow chart.

Upon entry to each state, the LED pin for the corresponding string is set to high. Upon exiting each state, the pin is set to low. I chose the low E string, the lowest of the six strings, as my default. When I first power the tuner on, it will start in this default state.

There are seven outputs on the Stateflow chart: one for the LED for each of the six strings, and one called “periodRange,” which I will discuss later. The six LED outputs go straight to Arduino digital output blocks to power the appropriate LED on or off.

Now let’s look at the audio processing portion of the model. The guitar signal comes in through the analog input block. I set the sample time of the block to be 0.0002 seconds for a 5-kHz sampling rate. When I played the guitar and opened the audio scope block, I was able to see a waveform like the one below.

The scope block helped me tune the potentiometer in the audio circuit to change the gain of the input. The gain should be set as high as possible without the waveform’s peak reaching the maximum value of 1023. This will allow for the most precise reading of the signal.

When the guitar is not played, the input signal should be a flat line somewhere between 500 and 700. In my case, it was around 550. It is important to know this value because the tuner should process the audio only when there is a note being played. I chose a value of 575, just above this flat line, to be my threshold. The audio will be processed only when the signal is above this threshold value. Since Simulink allows me to tune parameters while a simulation is running, I was easily able to set my threshold value.

When a single note is played on a guitar, the waveform generated is periodic. The period of the waveform corresponds to a certain musical pitch. The tuning algorithm estimates the pitch of the string by determining the period of the waveform. I wrote a MATLAB function that performs this pitch estimation, and included it in my Simulink model using the MATLAB function block. To determine whether the string is in tune, the MATLAB function needs an input indicating what range of periods is considered in tune for each string. This is the output “periodRange” from the Stateflow chart. The function determines whether the pitch of the string is too high, too low, or in tune based on the period range, and generates outputs for the motor accordingly.

The outputs of the MATLAB function are the three pins that control the motor. These outputs go straight to Arduino digital output blocks.

Once I ensured everything was just right with my algorithm, I was able deploy it to the hardware so that it could run standalone, without being connected to the PC and independent of Simulink.

Now I can tune my guitar automatically!

All the necessary files for this project are available here:

https://www.mathworks.com/matlabcentral/fileexchange/63697-automatic-guitar-tuner-using-simulink-and-arduino

Disclaimer: I’m an engineer, not a pro film maker. Be advised.

Disclaimer: I’m an engineer, not a pro film maker. Be advised.

 

 

 

 

 

motion detection system 1.jpg

The wireless motion detector project. Three drop-modules report to the monitor in the foreground.

 

 

Motion detectors are cool but running wires out to them is a drag. We wanted to secure an area quickly and conveniently and without sirens or bells letting intruders know that we know that they are trespassing. That means no wires.

And so, it was decided, a wireless motion detecting system would be built.

 

We could picture it in our minds, a portable, self-contained system that would let us know when our parents got home or when Derek was breaching the perimeter around our couch-cushion fort. Derek doesn’t respect perimeters.

 

Design considerations – selecting components

We started with Arduino Micros and went from there. We chose these because they are small and have an on-board USB controller. This allows them to be programmed simply by plugging them into a USB port, just like the UNO. No FTDI adaptors would be needed like as is necessary for compact boards like the Arduino NANO. The version of the Micro used came without pin headers soldered on. This for ease of assembly and to conserve space. The pins would have been harder to solder to and would have taken up a lot more room.

 

nRF24 1.jpg  

For the wireless bit, we selected the nRF24L01+ radios. Note the + at the end of the name. The “plus” models that have a male SMA connector for an external antenna and they have an alleged open-air range of 1000 meters when operated at maximum power.

 

nRF24 adapter 1.jpg

nRF24 radios are extremely finicky when it comes to their power. They do not tolerate supply noise at all. To put the stop to any issues of this sort before they start, we used an adapter board like this. They come with an AMS1117 linear regulator to keep the voltage to the radio at a steady 3.3 volts. They also have a few noise filtering capacitors to keep the power clean.

 

OLED screen 1.jpg 

An 128x64 i2c OLED screen was used to display the status of the sensors. An i2c connection was chosen on purpose. The nRF24 radio communicates via SPI. So, to prevent any conflicts that might arise from having the screen and radio on the same data bus, it was decided use i2c for the screen. Yes, theoretically there should be no problem with putting the two devices on the same data bus. But all too often, reality swings in to ruin your day and you are left screaming about how everything worked fine on paper. To minimize any handholds for Murphy’s and Sod’s Law, communications to the screen and the radio were kept completely separate.

 

PIR sensor 1.jpg

This is the PIR motion sensor used for the drop-modules. The potentiometers on the side control how sensitive the device is and how long the output stays high after motion is detected.

 

battery 1.jpg 

Lithium-polymer battery in the shape of 9-volt batteries was chosen as a power source for the drop-modules and the monitor. Originally, the intention was to use disposable alkaline or lithium 9-volt batteries. However, these types of batteries will not meet the power demands of the nRF24 radios. This point demands a bit of explanation. nRF24 radios draw very little “on” but quiescent. During the short period that they are transmitting their power requirement spikes abruptly. A typical 9-volt battery cannot provide the energy fast enough for the nRF24. This problem can sometimes be mitigated by installing a fairly large capacitor (100uF) in parallel with the battery. Another solution is to do what we did, use a lithium-polymer battery. The particular batteries we chose are very convenient for projects because they combine a lithium-polymer battery with a battery management circuit, a battery protection circuit, and a boost converter. They also have a micro USB port for charging. It’s like five components packed into the shape of a 9-volt battery. Note the tiny hole in the bottom of the battery. This is for a red LED that lights up when charging. The LED shuts-off when the battery is fully charged.

 

Monitor BOM

 

Drop-module BOM

 

 

The Code (Attached to this article)

Code was written up for the drop modules and the monitor. The code for each of the drop modules is identical. During the drop-module’s setup routine, the address selection pins are polled to see what the modules address is. Two modules cannot have the same address. If they did, the monitor will interpret all the received data as coming from the same drop-module, and the system will not work as intended.

 

An ad-hoc protocol was developed for communicating drop-module status back to the monitor. The drop-modules encapsulate all of their data into an unsigned long variable. Each byte of this variable would represent a specific alarm code or the status of the battery. Then, the entire unsigned long variable is sent to the monitor.

 

At the monitor, this variable is broken back down into bytes, and the data is used to determine what drop-modules are active, what its status is and if the signal from any module is dropped.

 

The code for the drop-modules and the monitor share a number of details. They both us the RF24.h library to handle interactions with the radios. Also, they both use the TimerOne.h library. Timer one is used to make sure events like transmitting status and updating the OLED display happen at regular intervals.

 

The monitor uses the U8g2 library to control the OLED.  This library is very easy to use, and it is loaded with easy to use functions for drawing lines and shapes and placing text on the screen. There is a huge selection of fonts to choose from too.

 

At a glance, the code, especially the monitor code looks complicated but don’t let it scare you. It is lengthy, but you have a couple things going for you. It is commented extensively, and it is written out in a longhand of sorts. This makes the code take up a lot more space than it needs to, but it is also easier to understand for the less experienced coder. Oh, and the bulk of the monitor code is subroutines used to refresh the OLED display.

 

 

The mechanical design (Files needed for 3D printing, attached to this article)

All the parts that we knew were going into the project were mocked-up in SolidWorks. The Arduino Micro, the nRF24, the 9-volt battery, the OLED screen. These mock-ups are mostly rough geometric approximations of the real parts. We don’t need a high level of detail to effectively design enclosures for the project.

 

SW monitor 1.png  

From here the enclosure for the monitor was drawn up. The enclosure takes style cues from sources like the Aliens movies and the short videos of Neill Blomkamp.

 

SW drop module 1.png 

Then the drop-module was drawn up. It is designed around a clear plastic toothpick container. The container is clear and just the right size to house all the parts.

 

Putting it all together

The monitor enclosure and the parts for the drop-modules were 3D printed in a pleasing dark blue color. There was nothing very complicated about the build. The components were wired together with short leads, soldered and then covered with heat-shrink tubing. The notable points of the build are illustrated in the pictures below.

 

 

The monitor

schematic - monitor .JPG

The monitor wiring diagram. Start here.

 

 

 

 

{gallery:autoplay=false} Monitor Assembly

monitor module 5 - nRF24 radio.pngHere is the radio installed in the monitor. Notice the two spacers around the SMA connector.

These keep the radio square to the interior surface when the antenna is threaded on - they were made by trimming an old credit card into washer shape with a hobby knife.

monitor module 2 - nRF24 adapter.pngThe pins and headers were de-soldered from the adapter board; this was done to conserve space.

Then, wires were soldered to the adapter and then the whole board was covered with a big piece of heat-shrink tubing.

monitor module 3 - power button.png

The on-off switch slides into the pocket designed to hold it.

monitor module 4 - resistor bridge 1.pngThe voltage divider network for monitoring the battery status was constructed with a pair of 10k resistors.

The entire assembly was covered in heat-shrink - the yellow wire runs to and ADC input on the Arduino MICRO.

monitor module 6.JPG

The reset buttons are pressed into their slots. Friction keeps them in place.

screen & bezel 2.jpg

The conserve space, the OLED screen sits in a 3D printed bezel.

screen & bezel 3.jpg

The screen drops right into the rear of the bezel.

screen & bezel 1.JPG

The screen installed on the outside of the monitor enclosure.

monitor module 8.jpg

Fold everything into the enclosure - be careful not to break anything.

monitor module 7.jpg

Once everything is tucked inside the monitor, fasten the rear covers down with #2 machine screws.

monitor module 1.jpg

Completed monitor - human hand for scale.

 

 

 

 

Building the drop-modules

 

schematic - drop module.JPG

The schematic for the drop modules. Notice the address selection pins 8, 9, and 10. To set the address of the module, a single pin must be connected to ground. Modules cannot share addresses.

 

 

{gallery} Building the drop module

drop module 1.png

The drop modules are assembled with the same methods as the monitor - you can see here that all the components are wired up and protected with heat-shrink tubing.

drop module 2.png

You can see here where the headers and pins have been de-soldered from the adapter board and the nRF24 and wire leads have been soldered in their place - the assembly is covered in heat-shrink after soldering.

drop module 3.png

The PIR sensor is hot-glued into its 3D printed shell.

drop module 4.png

To finish, carefully fold the everything into the containers and seat the tops. Then Slide the retaining ring over the bottom of the containers. Finally, fasten everything together with the long #6-32 screws and nuts. It is a good idea to label the drop-modules too.

 

 

 

How to use it all

 

 

 

 

Conclusion

 

There were a lot of different ways we could have come at this project. We could have used a mesh network that would have allowed for dozens or over a hundred drop-modules, but instead, we went with three. Also, the code could have been written far more efficiently. Especially the monitor code. For anyone who attempts this project we strongly suggest having a go at optimizing the code.

 

We used 3D printed parts and toothpick containers to house our project, but you don’t have to do any of that. Use breadboards and cardboard. Or use plastic food containers. It doesn’t matter. The code and the hardware are oblivious to how good (or bad) they look. Also, for your version of this project, you can use different sensors. You don’t have to use PIR motion detectors. You could use the drop-modules to keep an eye on anything. Use photoresistors to see if someone turns on a light. Replace the PIR sensor with a momentary pushbutton or a pressure sensitive doormat to make a wireless doorbell. Maybe you could use a drop-module with just a tilt sensor to let you know if someone is messing with your bike. Whatever you ultimately decide to do, this project gives you a solid basis to work from.

 

But for now, Derek won’t know what hit him.

 

 

-----------------------------------------------------------------------------------------------------

Have a story tip? Message me at: cabe(at)element14(dot)com

http://twitter.com/Cabe_Atwell

 

It’s no secret that lighting effects have been one of my major focuses in my career as a maker, and I wanted to share a pretty cool concept that I came up with a few years back. In this tutorial I will walk you through the process of creating a pair of accent lights that that utilizes the popular WS2812B LED modules also known as Neopixels, and an open source library called fastLED. Within this tutorial you will learn how to increment a variable with the push of a button, and how to utilize the colorPalette feature within the fastLED library.

 

Hardware

 

To complete this tutorial you will need the following items:

 

Software

 

To complete this tutorial you will need the following software. Click the links to open their download pages in a separate window.

 

Tools

 

You will also need the following tools.

    • Soldering Iron & Solder
    • Hot Glue Gun & Glue Sticks
    • Drill & Drill Bits
    • Scissors or Xacto Knife
    • Needle Nose Pliers

 

The Code

 

If you have used Adafruit’s Neopixels before, you have most likely used the Neopixel library as well. For this tutorial we are going to use a library called FastLED,  the library from which the Neopixel library was born. In reality you could create a very similar lighting effect with the Neopixel library, but the FastLED library comes with a pre-built example that will greatly speed up the code writing portion of this tutorial. Before you get started, make sure you have downloaded and installed the latest version of the Arduino IDE, and the FastLED library. If you are unsure as to how to install a library in Arduino, check out this document on Arduino.org.

 

I am going to explain this code section by section with a comment for each line that is important in hopes that it will make it easier to follow, but if you would like to see the full source code in its entirety, scroll down to the bottom of this section, or visit its repository on my Github. Now let’s get started!

 

Variable Declaration Section

 

In this section we need to include the libraries we will be using, define the variables and integers that our code will need to run properly.  There is also a line of code in this section that will let you reverse the direction in which the strip of NeoPixels will illuminate from. This is handy if your hanging lantern only has room to hide the Arduino in the top of its housing. This will let the LED strips still appear to flicker from the bottom to the top like a real candle would.

 

#include <FastLED.h>

#define LED_PIN     6         // the pin which attaches to the neopixel data pin
#define COLOR_ORDER GRB      // sets the color order in which the LEDs are designed for
#define CHIPSET     WS2812B  // the chipset that the neopixels use
#define NUM_LEDS    8      // how many leds are being adderessed

#define BRIGHTNESS  200         // sets the overall brightness of the leds
#define FRAMES_PER_SECOND 60    // how fast should the led animation render
#define COOLING  55      // defines the level at which the lighting effect fades before a new "flame" generates
#define SPARKING 120    // defines the rate of flicker which we will see from the flame animation

int switchPin = 2;              // switch is connected to pin 2
int val;                        // variable for reading the pin status
int buttonState;                // variable to hold the button state
int buttonPresses = 0;          // how many times the button has been pressed

bool gReverseDirection = false;  // set this to true if you need to invert the animation direction

CRGB leds[NUM_LEDS];     // sets up an array that we can manipulate to set/clear led data.

CRGBPalette16 currentPalette; // sets a variable for CRGBPalette16 which allows us to change this value later

 

Setup Section

 

This section is where we place the code that needs to be ran once before the loop when the arduino first powers up. Here we will initialize the the NeoPixel Strand and inform the library of the variables needed to help the Arduino send commands to the WS2812B chipset on each of the NeoPixel LEDs.

 

void setup() {
  delay(3000); // sets a delay to insure that everything has initialized before proceeding with the setup

  // Informs the library that a strand of NeoPixel's on pin 6 and those leds will use the led array "leds", and there are NUM_PIXELS (aka 8) of them.
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  
  FastLED.setBrightness( BRIGHTNESS );   // sets the brightness to the predetermined levels
  pinMode(switchPin, INPUT);    // Set the switch pin as input
  Serial.begin(9600);           // Set up serial communication at 9600bps
  buttonState = digitalRead(switchPin);   // read the initial state of the button

 

Loop Section

 

This section is where the code that needs to run in a loop is placed. The code you see below is where much of the magic happens. It takes advantage of the If / Else statement structure, and looks for the number of times the button has been pressed. If that number coincides with one of the numbers in the various if statements, then it will set the color palette being used to whichever color palette has been defined in that if statement. After the if/else statments, there is code that tells the Arduino to count and store the number of times the button was pushed, and once that number reaches 10, it will reset to 0 on the eleventh button push.

 

void loop()
{
  random16_add_entropy( random());  // Add entropy to random number generator; we use a lot of it.

   // The following if statements read the number of times the button has been pressed
   // and then sets the currentPalette variable to the defined CRGBPalette16 color palette.
   // for example: if the button has been pressed 1 time, set the palette to HeatColors. If
   // the button has been pressed 4 times, set the palette to a custom defined palette found in
   // that statement. The else statement at the end helps us return to the top of the if statments.

   if (buttonPresses == 0) {
    currentPalette = CRGBPalette16( CRGB::Black);
    }
  if (buttonPresses == 1) {
    currentPalette = HeatColors_p;
  }
  if (buttonPresses == 2) {
    currentPalette = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua,  CRGB::White);
  }
  if (buttonPresses == 3) {
    currentPalette = CRGBPalette16( CRGB::Black, CRGB::Green, CRGB::GreenYellow,  CRGB::Yellow);
  }
  if (buttonPresses == 4) {
    currentPalette = CRGBPalette16( CRGB::Black, CRGB::Green, CRGB::Purple,  CRGB::Orange);
  }
  if (buttonPresses == 5) {
    currentPalette = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Purple,  CRGB::Red);
  }
  if (buttonPresses == 6) {
    currentPalette = CRGBPalette16( CRGB::White);
  }
  if (buttonPresses == 7) {
    currentPalette = CRGBPalette16( CRGB::Yellow);
  }
  if (buttonPresses == 8) {
    currentPalette = CRGBPalette16( CRGB::Maroon);
  }
  if (buttonPresses == 9) {
    currentPalette = CRGBPalette16( CRGB::DarkBlue);
  }
  if (buttonPresses == 10) {
    static uint8_t hue = 0;
    hue++;
    CRGB darkcolor  = CHSV(hue,255,192); // pure hue, three-quarters brightness
    CRGB lightcolor = CHSV(hue,128,255); // half 'whitened', full brightness
    currentPalette = CRGBPalette16( CRGB::Black, darkcolor, lightcolor, CRGB::White);
  }
  else  {
  }


  Fire2012WithPalette(); // calls the function defined below this loop & runs simulation frames, using palette colors

  FastLED.show(); // display this frame
  FastLED.delay(1000 / FRAMES_PER_SECOND); // sets a delay using the number 1000 devided by the predetermined frames per second.

  val = digitalRead(switchPin);      // read input value and store it in val
  if (val != buttonState) {          // the button state has changed!
    if (val == LOW) {                // check if the button is pressed
      buttonPresses++;               // increment the buttonPresses variable
      Serial.print("Button has been pressed ");  // prints the statement between "" in the serial terminal
      Serial.print(buttonPresses);              // reads the value stored in the buttonPresses variable.
      Serial.println(" times");                // prints the statement between "" in the serial terminal
    }
  }
  if (buttonPresses > 10){    // reads the number of button presses, and if that number is greater than 10 then
  buttonPresses = 0;         // reset the number of button presses to 0 
  }
  buttonState = val;                 // save the new state in our variable

}

 

Function Section

 

This section is not officially a real section found in the Arduino IDE's documentation, but I like to give it a name to help organize my code for tutorials. The code in this section defines one or more functions that can be called in the setup or loop sections of the code. Here we are defining a function which is the original fire2012 code which has been modified to take advantage of FastLED’s color palette features.

 

void Fire2012WithPalette()   // defines a new function
{
// Array of temperature readings at each simulation cell
  static byte heat[NUM_LEDS];

  // Step 1.  Cool down every cell a little
    for( int i = 0; i < NUM_LEDS; i++) {
      heat[i] = qsub8( heat[i],  random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
    }

    // Step 2.  Heat from each cell drifts 'up' and diffuses a little
    for( int k= NUM_LEDS - 1; k >= 2; k--) {
      heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
    }
   
    // Step 3.  Randomly ignite new 'sparks' of heat near the bottom
    if( random8() < SPARKING ) {
      int y = random8(7);
      heat[y] = qadd8( heat[y], random8(160,255) );
    }

    // Step 4.  Map from heat cells to LED colors
    for( int j = 0; j < NUM_LEDS; j++) {
      // Scale the heat value from 0-255 down to 0-240
      // for best results with color palettes.
      byte colorindex = scale8( heat[j], 248);
      leds[j] = ColorFromPalette( currentPalette, colorindex);
    }
}

 

I have pasted the full code below, but you can also download it from my Github (https://github.com/CharlesJGantt/Neopixel-Realistic-Flickering-Candle-With-Changing-Color-Palette), or even create a fork if you would like to add more functionality on your own.

 

// Fire2012WithPaletteCycle
// Version 0.12 Revision 3


// Portions of this code originated in the FastLED library, and was
// modified & amended by Charles Gantt on 7/1/2017. Visit Charles' website
// at http://www.themakersworkbench.com


// Origial Fire2012 Code by:
// Mark Kriegsman, July 2012
// as part of "Five Elements" shown here: http://youtu.be/knWiGsmgycY


// This code is the same fire simulation as the original "Fire2012",
// but each heat cell's temperature is translated to color through a FastLED
// programmable color palette, instead of through the "HeatColor(...)" function
// with additional custom defined color palettes.
// The different palettes can be cycled through by a push of a button
// connected to pin 2, and 5V.


#include <FastLED.h>


#define LED_PIN     6          // the pin which attaches to the neopixel data pin
#define COLOR_ORDER GRB       // sets the color order in which the LEDs are designed for
#define CHIPSET     WS2812B  // the chipset that the neopixels use
#define NUM_LEDS    12       // how many leds are being adderessed


#define BRIGHTNESS  200        // sets the overall brightness of the leds
#define FRAMES_PER_SECOND 60   // how fast should the led animation render
#define COOLING  55           // defines the level at which the lighting effect fades before a new "flame" generates
#define SPARKING 120          // defines the rate of flicker which we will see from the flame animation


int switchPin = 2;              // switch is connected to pin 2
int val;                        // variable for reading the pin status
int buttonState;                // variable to hold the button state
int buttonPresses = 0;          // how many times the button has been pressed


bool gReverseDirection = false;  // set this to true if you need to invert the animation direction


CRGB leds[NUM_LEDS];     // sets up an array that we can manipulate to set/clear led data.


CRGBPalette16 currentPalette; // sets a variable for CRGBPalette16 which allows us to change this value later


void setup() {
  delay(3000); // sets a delay to insure that everything has initalized before proceeding with the setup


  // Informs the library that a strand of NEOPIXEL's on pin 6 and those leds will use the led array "leds", and there are NUM_PIXELS (aka 8) of them.
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );


  FastLED.setBrightness( BRIGHTNESS );   // sets the brightness to the predetermined levels
  pinMode(switchPin, INPUT);    // Set the switch pin as input
  Serial.begin(9600);           // Set up serial communication at 9600bps
  buttonState = digitalRead(switchPin);   // read the initial state of the button
}


void loop()
{
  random16_add_entropy( random());  // Add entropy to random number generator; we use a lot of it.


  // The following if statements read the number of times the button has been pressed
  // and then sets the currentPalette variable to the defined CRGBPalette16 color palette.
  // for example: if the button has been pressed 1 time, set the palette to HeatColors. If
  // the button has been pressed 4 times, set the palette to a custom defined palette found in
  // that statement. The else statement at the end helps us return to the top of the if statments.


  if (buttonPresses == 0) {
    currentPalette = CRGBPalette16( CRGB::Black);
  }
  if (buttonPresses == 1) {
    currentPalette = HeatColors_p;
  }
  if (buttonPresses == 2) {
    currentPalette = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Aqua,  CRGB::White);
  }
  if (buttonPresses == 3) {
    currentPalette = CRGBPalette16( CRGB::Black, CRGB::Green, CRGB::GreenYellow,  CRGB::Yellow);
  }
  if (buttonPresses == 4) {
    currentPalette = CRGBPalette16( CRGB::Black, CRGB::Green, CRGB::Purple,  CRGB::Orange);
  }
  if (buttonPresses == 5) {
    currentPalette = CRGBPalette16( CRGB::Black, CRGB::Blue, CRGB::Purple,  CRGB::Red);
  }
  if (buttonPresses == 6) {
    currentPalette = CRGBPalette16( CRGB::White);
  }
  if (buttonPresses == 7) {
    currentPalette = CRGBPalette16( CRGB::Yellow);
  }
  if (buttonPresses == 8) {
    currentPalette = CRGBPalette16( CRGB::Maroon);
  }
  if (buttonPresses == 9) {
    currentPalette = CRGBPalette16( CRGB::DarkBlue);
  }
  if (buttonPresses == 10) {
    static uint8_t hue = 0;
    hue++;
    CRGB darkcolor  = CHSV(hue, 255, 192); // pure hue, three-quarters brightness
    CRGB lightcolor = CHSV(hue, 128, 255); // half 'whitened', full brightness
    currentPalette = CRGBPalette16( CRGB::Black, darkcolor, lightcolor, CRGB::White);
  }
  else  {
  }




  Fire2012WithPalette(); // calls the function defined below this loop & runs simulation frames, using palette colors


  FastLED.show(); // display this frame
  FastLED.delay(1000 / FRAMES_PER_SECOND); // sets a delay using the number 1000 devided by the predetermined frames per second.


  val = digitalRead(switchPin);      // read input value and store it in val
  if (val != buttonState) {          // the button state has changed!
    if (val == LOW) {                // check if the button is pressed
      buttonPresses++;               // increment the buttonPresses variable
      Serial.print("Button has been pressed ");  // prints the statement between "" in the serial terminal
      Serial.print(buttonPresses);              // reads the value stored in the buttonPresses variable.
      Serial.println(" times");                // prints the statement between "" in the serial terminal
    }
  }
  if (buttonPresses > 10) {   // reads the number of button presses, and if that number is greater than 10 then
    buttonPresses = 0;         // reset the number of button presses to 0
  }
  buttonState = val;                 // save the new state in our variable


}


void Fire2012WithPalette()   // defines a new function
{
  // Array of temperature readings at each simulation cell
  static byte heat[NUM_LEDS];


  // Step 1.  Cool down every cell a little
  for ( int i = 0; i < NUM_LEDS; i++) {
    heat[i] = qsub8( heat[i],  random8(0, ((COOLING * 10) / NUM_LEDS) + 2));
  }


  // Step 2.  Heat from each cell drifts 'up' and diffuses a little
  for ( int k = NUM_LEDS - 1; k >= 2; k--) {
    heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
  }


  // Step 3.  Randomly ignite new 'sparks' of heat near the bottom
  if ( random8() < SPARKING ) {
    int y = random8(7);
    heat[y] = qadd8( heat[y], random8(160, 255) );
  }


  // Step 4.  Map from heat cells to LED colors
  for ( int j = 0; j < NUM_LEDS; j++) {
    // Scale the heat value from 0-255 down to 0-240
    // for best results with color palettes.
    byte colorindex = scale8( heat[j], 248);
    leds[j] = ColorFromPalette( currentPalette, colorindex);
  }
}

 

Assembly

 

The assembly process is not very hard, but it is fairly time consuming. It involves the use of a soldering iron, high speed drill, and a hot glue gun. If you are unsure as to how these tools operate, please read their instruction manuals before continuing along with this tutorial. Additionally, remember to wear safety glasses, and hearing protection when using power tools.

 

IMG_1065.jpg

 

Before we get started let’s take a moment to inventory the parts that we will need to complete this tutorial. You should have the following items:

    • 2X Votive Lantern
    • 2X Arduino Nano
    • 4X Neopixel Sticks
    • 2X Tall Tactile Buttons
    • 2X 10k Resistors
    • 2X USB A - USB Mini Cables
    • Hookup Wire
    • Soldering Iron & Solder
    • Glass Frosting Spray
    • Vellum or Tracing Paper
    • Hot Glue Gun & Glue Sticks
    • Black Craft Foam

 

IMG_1070.jpg

 

For the purposes of this tutorial, I am going to be building one of the lanterns. I will be making a build video with the second lantern. I picked this lantern up at a local home decore store, but I have seen them for sale on Ebay, Amazon, and a lot of other online retailers. You do not have to use this specific lantern, and any votive candle lantern, wall sconce, or even a more traditional hurricane lantern will work.

 

IMG_1073.jpg

 

To get started, we need to remove the glass panes and prep them for the frosting spray. For this particular lantern and most others like it, each glass pane is held on by four small metal tabs, as seen in the image above, that will need to be folded back to allow the pane to be removed. The glass pane’s are usually quite sharp, with their edges chipped from rough handling at the factory, so be careful, and consider wearing gloves when removing and handling these glass panes.

 

IMG_1077.jpg

 

With the glass panes removed, you can see how sharp and jagged their edges are. Now take the panes outside, or somewhere that is very well ventilated as the frosting spray produces noxious fumes when drying.

 

IMG_1078.jpg

 

To ensure that the frosting spray achieves good adhesion the glass needs to be free of any oily residue from handling it. I have found that using 91% isopropyl alcohol is best for cleaning the glass. I just wipe the glass with an alcohol moistened paper towel until the fingerprints disappear, then wait 10 minutes or so to ensure that all of the alcohol has evaporated.

 

IMG_1080.jpg

 

With the glass clean, I held the frosting spray about 10-inches away from the panes and sprayed a nice wet coat onto the glass. The instructions said to wait about 7 minutes and apply another wet coat. Then I waited for about 10 minutes and added another coat, this time about 14-inches from the surface and lighter than the last two. I repeated this step three more times until I was happy with the opacity of the panes.

 

IMG_1146.jpg IMG_1148.jpg

 

With the glass panes dry, I set them aside and started work on the electronics. Here you can see how opaque the frosting spray made the glass. The frosting spray works well, but we will still have to diffuse the light even more and we will discuss that more later. When setting the panes aside, do not stack them, or place anything on top of them as the frosting spray is pretty fragile and will scratch very easily.

 

IMG_1090.jpg

 

For this project I am using some 4-inch strips that I cut from a 5-meter roll of 140 pixel per meter NeoPixels that I had leftover from a previous project. The Neopixel sticks that I link to at the beginning of this tutorial work much better for this type of project, but unfortunately, my order was delayed and I did not receive the sticks in time for this tutorial.

 

IMG_1094.jpg

 

Before we get started wiring things together, the official Arduino Nano V3  comes with its header pins preassembled. I prefer to get the boards unassembled, but that is only possible with the off-brand variants of the nano. Because of this, the SPI header makes the nano a little too tall for our project, so I need to remove the six pin header on top of the board.

 

IMG_1100.jpg

 

To do remove these pins, I clamp the board in my small bench vice, and use my soldering iron to heat each pin’s solder joint while pulling on that pin with a pair of small needle nose pliers. Once the joint reaches molten temperatures, the pins pull right out. When doing this yourself, remember to not clamp the board too tight, as you could cause it to flex and break loose the surface mount connections of the small ICs and passive components.

 

IMG_1101.jpg

 

Here you can see that all of the SPI header pins have been removed, and nothing but small solder balls are left on the pads. I should have done this to the entire board as doing so would have provided me with a cleaner install. When I originally designed this project several years ago, I actually used Arduino Pro Mini boards which come with the header pins unsoldered. Eventually I developed my own purpose built PCB for this project, but that board was proprietary to the company I used to own, so unfortunately, I can not share it here. I could design a new board if there is enough interest though.

 

IMG_1106.jpg IMG_1109.jpg

 

While we are modifying the Arduino Nano to better fit our project, we need to cut some small strips of black craft foam which we will hot glue to the Nano’s surface to insulate it from the metal bottom of the lantern. Since the USB port sits several millimeters proud of the PCB’s surface, I cut a smaller piece of foam to help level things out for the larger piece which will cover the full surface.

 

IMG_1113.jpg IMG_1115.jpg

 

Here you can see how I glue the foam to the Nano to ensure that the final result is nice and flat. It is important to note that you should not cover the Nano’s reset button with hot glue, and make sure to not depress it when pressing the foam into the glue. If you accidentally get glue on the button, just let it dry and remove it with your fingers or the needle nose pliers. Also note that I used two very small drops of glue on each end of the small strip of foam for this very reason. Once the glue has dried, try depressing the button. It should click, which is an indication that it is not stuck with glue.

 

2017-07-12 03_46_23-Start.png

 

Wiring up the hardware is fairly straightforward. Following the Fritzing diagram above make the following connections. It’s important to wire the Neopixel sticks exactly the same so that their animations sync up later on.

 

    1. Arduino Nano Digital Pin 2 to Button Pin  1
    2. Arduino Nano Digital Pin 2 to Resistor Pin 1
    3. Resistor Pin 2 to Arduino Nano GND
    4. Button Pin 3 to Arduino Nano 5V
    5. Neopixel Stick 1 5V to Arduino Nano 5V
    6. Neopixel Stick 1 GND to Arduino Nano GND
    7. Neopixel Stick 1 Data In to Arduino Nano Digital Pin 6
    8. Neopixel Stick 2 5V to Arduino Nano 5V
    9. Neopixel Stick 2 GND to Arduino Nano GND
    10. Neopixel Stick 2 Data In to Arduino Nano Digital Pin 6

 

 

IMG_1122.jpg

 

Let's begin by focusing on the Neopixel sticks / strips. Since I am using flexible strips that have been cut into 4-inch long pieces, I need to add something rigid to them to ensure they stand up nice and proud later in the build. I simply use a popsicle stick that I cut with an x-acto knife to be slightly thinner and shorter than the strips. Typically, the only glue that will bond to the strips is something super tacky like E6000, which just so happens to be my third favorite glue, and something I stock in my workshop by the half dozen. If you are wondering, Cyanoacrylate (CA) and hot glue are my other two favorite types of glue.

 

IMG_1123.jpg IMG_1125.jpg

 

I spread a small thin line of the glue across each strip, and then sandwiched the popsicle stick between the two strips. E6000 is quite the potent glue, and it would be advisable to have a small fan running near your workbench to avoid over inhalation of its fumes.

 

IMG_1127.jpg IMG_1129.jpg

 

To ensure that the strips stayed oriented on the popsicle stick, I used a pair of small zip ties to secure them to the stick. Then I placed the sandwich between two scrap pieces of wood, and used small clamps to apply gentle pressure until the glue cured about an hour later.

 

IMG_1132.jpg

 

Here you can see a closeup of the stick once it had cured and was ready to solder some wires to. I decided to leave the zip ties on for added insurance.

 

IMG_1133.jpg

 

I forgot to mention earlier that you should orient both strips so that their Data In pins are on the same end of the stick. This makes wiring up the Neopixels a little more difficult, but it is necessary to achieve the effect we are going for.

 

IMG_1134.jpg IMG_1135.jpg

IMG_1137.jpg IMG_1142.jpg

 

I pre tinned the hookup wires before soldering them to the Neopixels. In the second photo (click to enlarge) you can see how I hook the strips together. Since the strips are mirrored from each other, I need to cross over the 5V and GND lines, but the Data In pin remains in the middle. This process is much easier with the Neopixel sticks than it is with these high density strips which have very small solder pads.

 

IMG_1143.jpg

 

Before we solder our wires to the Arduino Nano, cut a small passageway into the top of the foam. This will allow us to pass the Neopixel’s wiring under the Arduino when installing the electronics.

 

IMG_1116.jpg

 

In an attempt to make the install even more low profile, I decided to bend over the pins I would be using, which would allow me to lay the wires down instead of having them stick up and possibly create shadows. As I mentioned earlier, this was a mistake, and I should have desoldered all of the pins from the board, and soldered the wiring directly to the pads. This would have resulted in a much cleaner install, but I guess you live and learn, and in reality, no one will see the mess that is to come once the lantern is finished.

 

IMG_1144.jpg

 

With the pins bent over, it's time to solder the Neopixel’s wires to the Arduino Nano. Refer to the diagram above if you forgot which pins each wire connects to. You can see here how messy this looks, but it's functional, and will not be visible in the completed project, so it's not that big of a deal honestly.

 

IMG_1158.jpg

 

Now it’s time to wire up the button. Notice that I hold it in a pair of helping hands. This makes things easier as one alligator clip can hold the button while the other holds the wire in place. If you are worried about mixing up the pinout on the button, as long as you solder one wire to a pin, and then solder the other wire to the opposite corner, the orientation will be correct.

 

IMG_1165.jpg

 

Here you can see the orientation of the wires on the button. I would leave a good three to four inches of wire length to help make installation easier.  You can also see that I added a layer of black foam to the other side of the Arduino Nano as well. I did this to cover up the mess that you will see in the next photo.

 

IMG_1162.jpg

 

With the button soldered in place, I needed to add the resistor Digital Pin 2 and GND on the Arduino. The button press counting code will not function correctly unless  this pull-down resistor is in place. If you wanted a cleaner layout, you could utilize the 5V and GND pins on the SPI header that we removed earlier. With the electronics finished, this is the time to upload the code to the Arduino Nano. I am not covering that part of the project in this tutorial because if you do not know how to do that, you need to head over to the Arduino website, and walk through their getting started guide.

 

  IMG_1145.jpg IMG_1167.jpg

IMG_1168.jpg IMG_1169.jpg

 

Now that the electronics are finished, it's time to reinstall the glass panes in the lantern body. But before we do that, we need to drill a 7/16-inch hole in the top of the lantern as close to its hanger loop as possible. This will allow us to run the USB cable down into the lantern to provide power to the Arduino Nano. You will also need to touch up the paint on the lantern as the drill will cause some minor scratches and the hole’s rim will need paint.

 

IMG_1154.jpg

IMG_1156.jpg IMG_1157.jpg

 

This is also the time to drill the hole in the bottom for the button. In my case a 3/16-inch drill bit was needed. I like to use a small piece of sandpaper to clean the bur from the hole, and to scuff the surface which will make the hot glue we will use to secure the button stick better.

 

IMG_1150.jpg

 

Installing the panes is as simple as reversing the steps you took to remove them. This time you need to be very careful as to not scratch the frosted coating on the lanterns sharp edges. It’s also worth noting that if you have sweaty hands, this would be a good time to wash them and wear gloves, as the oils from your skin will visibly stain the frosted coating.

 

IMG_1152.jpg

 

Here you can see the difference in the frosted glass versus the clear glass. The clear glass is nice when using an actual candle, but since we are using LEDs it must be frosted to hide the electronics. I actually prefer the frosted look myself. This would be a good time to point out that I chose these lanterns because of the one inch tall wall at the bottom. This wall is tall enough to hide the shadow that will be cast by the LEDs when illuminated. Keep this in mind when choosing your lantern. Alternatively you can hide the electronics in the top of the lantern and uncomment the line near the top of the code that will reverse the led animation’s direction of flow, which will allow you to hang the Neopixel sticks from the top, and it still look like the flame is flickering from bottom to top.

 

IMG_1170.jpg IMG_1171.jpg

 

Now let's begin installing the electronics! The first thing we need to attach is the button, and that’s quite simple to do! Place the button in the small hole, and then cover it in a nice thick layer of hot glue, then hold in place using the wiring until the glue solidifies. Try your best to not get any glue between its mandrel and the button body itself as this could prevent it from working.

 

IMG_1173.jpg

 

Now apply a small strip of hot glue to the corner closest to the back of the lantern in relation to the middle of the door. Then press the USB cable into the hot glue making sure to leave just enough room to connect it to the Arduino Nano.

 

IMG_1174.jpg

 

With the USB Cable in place, its time to use two small dabs of hot glue to secure the Arduino nano in place. Plug the USB cable in before doing this. If you are worried about the cable pulling out through the top, you can zip tie a ½-inch steel nut to it in top of the lantern. I have found the hot glue to be sufficient though.

 

IMG_1182.jpg

 

Installing the Neopixel sticks is a little bit tougher than the other components and it requires a steady hand. Once the stick has been placed as close to the center as possible, I use my glue gun to apply hot glue from the first pixel down. I make sure that some of this glue actually coats the first pixel, which gives it a bit more rigidity. Once this first layer of glue is solidified, I add another layer making even more contact with the stick. Note that I did not include a photo of the surface of the lantern under the stick. I scuffed it up with 80-grit sandpaper before applying the glue. After 2 or 3 layers, the stick should be stuck firmly into place, and very rigid. It is important to ensure that no metal from the solder connections are touching the metal surface, and you can add a thin layer of hot glue to the surface before gluing the stick in place if you are worried about this.

 

IMG_1183.jpg

 

Now we need to take the velum paper and create a small cylinder shaped diffuser. This is necessary because the frosting on the glass is not enough to fully diffuse the circular light pattern the LEDs project. Since the stick is about 4-inches tall, I made my diffuser about 5-inches tall, and secured its ends together with a piece of double sided tape. Glue will work fine here as well, but you want the thinnest layer possible to prevent a dark spot in the diffuser.

 

IMG_1186.jpg

 

Since the blob of hot glue holding the Neopixel stick up is so large, I had to cut out some of the diffuser on the bottom to make it fit. I got it as close as possible, and even though a few gaps were showing, I knew that it would be pointed towards the back of the lantern and not visible from the front.

 

IMG_1188.jpg

 

To secure the diffuser in place, I used a few dabs of hot glue. With this in place, we simply need to hook up our USB cable to a power source and things are finished. I did notice that the lantern’s brightness was a bit high, so I plugged the USB cable into my PC and adjusted the brightness to about 125 by changing the code near the beginning of the code.

 

 

Conclusion

 

 

Overall I am quite pleased with the end result, but I am still bothered by how messy the electronics connections to the Arduino were. I decided to desolder all of the pins in the second lantern to make things a bit cleaner. Since I used 10-foot USB cables, I can hang these lanterns almost anywhere and still have enough cable to connect them to a wall outlet, and since they are USB powered, I can use a USB battery pack to power them on excursions like camping trips, over by our fire pit in the backyard, or even in Halloween decorations in our front yard this october.

 

That is going to wrap up this tutorial, and I want to thank you for taking the time to read through it. This project was quite fun, and is something you can accomplish in an afternoon by yourself or with others, and still have a project that is quite impressive when finished and the lights are turned off. I would love to hear everyone’s feedback on this project, so please feel free to leave a comment below.

Introduction

This project aims to solve two issues I have experienced working with 3D printers: controlling the filament consumption while the 3D printer is working. After exploring several possible approaches I decided that the most reliable solution should be based on the weight control.

The ability to dynamically measure the plastic material (filament) in use by a 3D printer includes some interesting non-obvious aspects helpful in many phases of the 3D printing process.

 

Updates

On June, 30 this project has been featured on Tindie Blog | 3D Printer Filament Weight/Length Monitor

November, 11. You can find the new version of this project with Bearings and some reviewed components for better working on Shopify: 3D Printer Filament Monitor for Arduino

 

Weight vs length and vice-versa

3D printers filament is sold in weight; the most common packages are 1 or 2 Kg filament rolls. The reason is that the product format, i.e. the filament in our case is the most important aspect for the end-user but meaningless for producers. Producers just sell kilograms of plastic material (PLA or ABS); the filament is the form factor provided on the market for a specific usage. I suppose that the same company that provides PLA filament it is not excluded will also provide the same material in other formats (e.g. plates, powder, pipes, film etc. for other applications). But for a similar reason 3D printers users needs to measure their filament in length. Slicer algorithms calculate the meter of filament needed for a certain 3D printed object so it is important to know how much meters remain in the roll before starting a new object printing and how many meters are used during a print job.

We know the specific weight of the materials used for 3D printing: PLA and ABS have different specific weight and this is a constant value. We also know the filament diameter; this means that 1 Kg 1.7 mm diameter filament will be longer than 3 mm diameter filament, same weight.

Calculating the conversion between weight and length it not so difficult knowing these parameters. You can just play with an algorithm with this nice online filament calculator.

 

Finding and testing the load sensor (scale sensor)

The first step was to find the right weight sensor and test its sensitivity. I should thank to michaelkellett that addressed me in the right direction; I bought a first series of four scale sensors in the weight range of 0-5 Kg and about half gram sensitivity for 3$/piece including the HX711 based amplifier circuit (the IC datasheet is in attach to the bottom of this post)

IMG_20170602_151947.jpg

IMG_20170602_181610.jpgIMG_20170602_181559.jpg

Using a 3 mm MDF sheet I have created a simple test sample to see the kind of data I should expect; after writing a few lines of code to show the readings on the serial terminal from an Arduino UNO I got a satisfying result and I definitely adopted this hardware solution.

 

The filament roll scale design

IMG_20170603_164430.jpg

Recycling the idea of my 3D printer filament spool holder design I have made the design of a compact scale supporting a rotating filament roll as shown in the images below. As shown in the 3D representation the filament roll lies on the four wheels that rotates free and the support is connected to the base through the scale sensor.

Scale only 01.jpgScale only 02.jpg

One support can be entirely built 3D printing 22 pieces with some M3 and M4 Allen screws and nuts at a very low price

Scale parts NoMotion.jpg

 

Assembling the parts

After all the 22 pieces has been printed can be easily assembled together. The top and bottom surfaces will be the filament spool support and the weight material scale at the same time. The filament is tensioned by the extruder so the roll should be free to rotate lying on the four free wheels (the orange ones). As shown in the assembly steps in the image gallery below top and bottom sides of the support are joined through the load sensor. It should be in the range 5-10 Kg max to support the filament roll that weight between 1,5 Kg and 2,5Kg (2Kg plastic rolls).

 

{gallery} Scale roll support parts and assembly

IMG_20170604_083158.jpg

3D printed base

IMG_20170604_083249.jpg

3D printed top

IMG_20170604_110124.jpg

The free wheels supports

IMG_20170604_110206.jpg

The free wheel supports

IMG_20170604_111634.jpg

The free wheel supports mounted on the top part

IMG_20170604_113020.jpg

The top part with the free wheels assembled

IMG_20170604_113048.jpg

Free wheel detail (top support)

IMG_20170604_113735.jpg

The base with the four calibration screws, top view

IMG_20170604_113742.jpg

The base with the four calibration screws, bottom view

IMG_20170604_113808.jpg

Calibration screw with spring of the base

IMG_20170604_114430.jpg

The base with the load sensor mounted, bottom view

IMG_20170604_114438.jpg

The base with the load sensor mounted, top view

IMG_20170604_114500.jpg

Base and load sensor assembled

IMG_20170604_115110.jpg

The top support mounted on the base through the load sensor

IMG_20170604_115135.jpg

The final assembly side view

 

IMG_20170609_092458.jpg

Testing the support 3D printing

IMG_20170609_092507.jpg

Testing the support 3D printing

 

Some structure improvements

Testing the first version of the 3D printed scale I saw that filament rolls can have different spool dimensions, also if the same weight. To manage the different widths between spools (may depends on different providers or different production batches) the top base design has been update; now it is possible to set the position of the four free wheels supports as shown in the images below.

IMG_20170612_091713.jpg IMG_20170612_091718.jpg

IMG_20170612_092704.jpg IMG_20170612_092712.jpg

IMG_20170612_093404.jpg IMG_20170612_093411.jpg

The wires coming from the load sensor are very thin and delicate so I decided that it was too risky to add a connector do I decided to include in the scale building also the HX711 filter adding two holes to the bottom part to fix the small IC board.

IMG_20170612_094140.jpg IMG_20170612_094150.jpg IMG_20170612_094826.jpg

IMG_20170612_091731.jpg IMG_20170612_100247.jpg IMG_20170612_100254.jpg

IMG_20170612_100721.jpg IMG_20170613_142926.jpg IMG_20170615_193450.jpg

 

Circuit and wiring

The image below shows the functional design of the circuit and the interface

Screen Shot 2017-06-24 at 21.18.49.png

As the filament is usually available in two different dimensions, 1.75 and 3 mm diameter, the rolls are available in different weights and we should consider using at least two kinds of materials it was necessary to provide a three dip switch to select these three settings before starting the system. Making the first experiments I saw tat it was impossible to distinguish automatically the three phases when a 3D print job starts:

 

1. Power the system and initialise it (calculating the empty tare without the filament)

IMG_20170615_193117 (1).jpg

2. Place the filament roll and wait the weight stabilises

IMG_20170615_193146 (1).jpg

3. Start reading the usage (material load)

(consumption can be expressed in grams or centimeters)

IMG_20170615_193403 (1).jpg IMG_20170615_193450.jpg

I have added two push buttons; an action button to manually set the three phases and a measure unit switch to select the visualisation on the display: filament units in grams or in centimeters/meters.

To have a complete status of the hardware a 3mm orange LED blink during every weight reading cycle while for the display I have used a shift register display (the full documented project is in these two articles: Enrico Miglino on ElectroSchematics.com  and Arduino 16x2 LCD Shift Register Library - Part 2 ) based on 74HC595 shift-in register I have built in past to reduce the usage of Arduino pins.

As the MC711 already generates a digital signal only two pins are needed to connect it to the Arduino board.

 

The project in action

The video below shows the first prototype and the final building in action after software filtering calculations have been included in the building.

The initial part of the video shows how connecting the sensor only without controls, due to unpredictable weight fluctuations it is almost impossible to control the three phases mentioned above while the second part shows the final version accordingly with the wiring scheme.

 

The software

The Arduino sketch is built in two parts for better readability: an header file defining all the constants used by the calculations as well as the pin settings and the source functions in the .ino file. All the project is distributed under the LGPL 3.0 license and is available on GitHub: https://github.com/alicemirror/3DPrinterFilamentMonitor-LCD

Additional libraries added to the sketch are the bodge MX711 library fo manage the scale IC and the updated library for the shift-LCD fixed compatible with the last versions of Arduino IDE, available in attach to this post.

Project build Index:

Arduino Project : Three-Finger Ring - Part 1 Getting started and 3D Printing

Arduino Project : Three-Finger Ring - Part 2 Code & the Circuit

Arduino Project : Three-Finger Ring - Part 3 Assemble the Ring!

 

----------------------------------------------------------------------------------

 

Step 6: Assemble the ring and install the components.

At this point, disassemble the breadboarded circuit and begin installing it into the ring. Glue and a hobby knife are essentials in this step. Unless you got lucky or have a printer that fabricates with a nigh-zero deviation from mathematical perfection, you will need to use a hobby knife to trim the printed parts.

 

The power pack is made by sandwiching the batteries together with a positive and negative wire and wrapping the whole affair tightly with electrical tape (Figure 5).

 

Hot glue was used to fasten the parts in place (Figure 6).

 

The #4 screws are used as pins for the hinge and to fasten the ring’s lid down (Figure 7).

 

battery pack.jpg  

Figure 5: The ring battery pack. It is a bit inelegant, but it works.

 

assembling 1.JPG

Figure 6: Glue the parts into the ring.

 

screw it together 1.jpg 

Figure 7: The #4 screws fasten the ring together.

 

 

 

 

Step 7: Power it up and show it off.

You might want to create some fresh images for your ring. Our pics didn’t increase our popularity quite as much as was hoped. Here are a few examples.

 

 

element 14 (12).JPG

danger (9).JPG

eulers relation (3).JPG

konami code (12).JPG

i 8 sum pi (8).JPG

max power (4).JPG

nerd life (8).JPG

ohms law (5).JPG

QT pi (6).JPG

stud muffin (28).JPG

final form (9).JPG

 

 

 

 

Final Notes:

We used a 128x64 OLED screen with that goofy yellow and blue background color. You can use whatever screen you want (almost whatever screen) as long as you adhere to a few guidelines. Make sure that the screen communicates via I2C.

 

The circuit and code do not use the RESET line. If the screen you get does have a RESET line, pull it HIGH by wiring it to the 5V output on the Trinket Pro.

 

If the resolution of the screen is anything other than 128x64 pixels, you will have to:

  • Size your images appropriately using a picture editor. You will not be able to use the CPP arrays in the provided code. You will have to create new arrays for your screens exact resolution.
  • You will have to adjust the U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NO_ACK) line in the code so that the U8glib library knows what screen size to work with. There are no provisions in the code or the hardware for detecting any information on the screen, so you have to tell it what is going on.

 

You are not obligated to use two CR2032 batteries to power your ring. Use a Li-Po battery back, an AAA with a boost converter, whatever. It doesn’t matter. The Trinket Pro can be powered by anything from 5.5-16 volts. If you wanted, there is no reason why a tiny Lithium-polymer battery and a battery management board couldn’t be used in place of the coin cells. Or a solar cell in conjunction with a super-cap or rechargeable battery.

 

Thanks for reading! Good luck with you own ring project!

Project build Index:

Arduino Project : Three-Finger Ring - Part 1 Getting started and 3D Printing

Arduino Project : Three-Finger Ring - Part 2 Code & the Circuit

Arduino Project : Three-Finger Ring - Part 3 Assemble the Ring!

 

----------------------------------------------------------------------------------

 

You have everything ready from Part 1 right? Good. Now it's time to program and get images on that screen.

 

Step 4: Breadboard the circuit.

 

Before installing anything, test it on a breadboard. That way, it will be so much easier to troubleshoot. See the electrical schematic in Figure 4.

 

breadboarded.jpg

Figure 3: Breadboard the circuit before installing it.

 

schematic.JPG

Figure 4: The electrical schematic for the Screen Ring.

 

 

Step 5: Upload the code to the Trinket.

 

There are a few special considerations for using the Adafruit Trinket. The IDE available from the Arduino site does not natively support it. You will need to either download a special version of the IDE from Adafruit with the board data pre-loaded, or you will have to follow the instructions on the Adafruit website detailing how to load the board data into the IDE. Either way, you will need to start HERE at the Adafruit introduction to the Trinket.

 

The cornerstone of the Screen Ring code is the U8glib library. It takes care of all the heavy lifting regarding control of the screen. The specifics of this library are well beyond the scope of this article but, if you want to learn more about it, start HERE.

 

 

Step 5-2: Create some sweet bitmaps for the ring.

The Arduino code cannot read PNGs or JPGs and the like. It requires BMP images to be converted into data arrays which are then pasted into the code. One of the easiest ways to accomplish this is to use the online image2cpp converter. Just upload a BMP, convert it and then copy the generated code into the Arduino sketch (Figure 5).

 

There are some rules for getting the converted images to display properly. This can all be done in Windows Paint.

  • Images must be in black and white.
  • Images must be created with a size of 128x64 pixels.

 

start of Array.JPG

Figure 5: The beginning of an array pasted into the sketch.

 

 

Resources: The CODE.

 

Attached to this post is code used in the Three Finger Ring.

 

In it, you can change the code to for any images you convert.

Project build Index:

Arduino Project : Three-Finger Ring - Part 1 Getting started and 3D Printing

Arduino Project : Three-Finger Ring - Part 2 Code & the Circuit

Arduino Project : Three-Finger Ring - Part 3 Assemble the Ring!

 

----------------------------------------------------------------------------------

 

CROP+DSC05498.jpg

 

I already teased this project back on "Geek Day," June 9th 2017. It's now completely finished!

 

This writeup will go over all the steps taken to build the screen ring. However, you dear reader won’t have to personally execute every step. You have the option of skipping steps because we will provide the 3D models for the ring and the accompanying code. You can procure the parts and print the ring without any of the design work. The one aspect of the design that you may have to change is the size of the holes in the ring to accommodate finger size.

 

In this section, we are going over all the mechanical aspects of the ring. What parts to gather. And how to get the ring 3D-Printed. (Part 2 is where we will cover the circuit design and code.)

 

Step 1: Decide on the parts to use.

 

For the dangerous end of the ring, we used a 128 x 64 pixel 0.96-inch OLED screen, very similar to this screen here. The exact screen we used is permanently blue with a yellow band across the top third. The yellow top third was probably originally intended to display data like the time and the battery charge.

An Adafruit Trinket Pro 5V provided the brains. It has far more IO than is needed but that’s OK. All those extra pins and features can be used on the next version of the Screen Ring.

 

While the options for powering the ring are many, we went with a couple of CR2032 coin cells. Each coin cell outputs 3V so stacking two of them in series yields a handy 6 volts. This is just enough to power the Trinket and for the Trinket’s onboard MIC5225 to regulate the voltage down to 5V for the OLED screen.

 

Bill of Materials

Quantity 1 - OLED Display, 128x64, I2C

Quantity 1 - Tactile Switch or something roughly equivalent

Quantity 2 - Adafruit Trinket Pro 5V

Quantity 2 - CR2032 coin cells

Quantity 3 - 10k resistor

Quantity 4 – #4 x 0.5” (12.7mm) machine screws

 

Step 2: Design the ring.

 

The ring was designed in SolidWorks, but any 3D CAD software like LIBRECAD or FREECAD will work. Again, you don’t have to design anything if you don’t want to. However, for the those who would attempt it, here is a bit of design advice.

  • It always helps to have at least a nebulous concept in mind.
  • Start by creating 3D models of the parts you know will be used. In this case, the screen, the batteries, the button and the Trinket. The level of detail applied to each of these models is up to you. You may not need to model the Trinket down to the point where all of the components on the board are represented. However, it would be a good idea to at least make the model large enough to fill the immediate space around the Trinket.
  • Start with a box big enough to hold all of these.
  • Position your parts inside the box where you think you would like them.
  • Start removing material where you don’t need it and adding it where necessary. For example, you might add bosses or studs for holding parts.

 

Once this "box full of parts" was designed, it was obvious that a single finger wasn’t going to be enough support it. For stability and coolness, it was decided that three rings bridged together would do the job. To get the size just right, a few of the ring-only sections were printed up and tested on actual hands.

 

3D modeling in progress.jpg

Figure 1: 3D modeling in progress. (NOTE: This image is far from the final design)

 

 

Step 3: Print the ring.

 

The 3D models can be sent off to a service like Shapeways or you can print them up yourself if you have access to a printer. For the ring seen here, we used our MakerGear M2. A quick shout out to MakerGear, the M2 deserves all the approbation it gets. It really is a workhorse.

 

We used this particular blue color (Figure 2) because it’s cool and kind of makes things look like they’re from the future. Oh, and because we had several rolls of that color already on hand.

 

the printed bits.jpg

Figure 2: This blue color is so rad.

 

 

Resources: 3D Models.

 

Attached to this post is a collection of the 3D models used in the Three Finger Ring.

 

You could use this as a starting point for your custom design too.

The Arduino platform has become quite popular with people just starting out with electronics. It is an open-source hardware design, based on microcontroller board designs and provide sets of digital and analog I/O pins that can be interfaced to various expansion boards ("shields") and other circuits. The boards feature serial communications interfaces, including USB on some models, for loading programs from personal computers.

Completing an Arduino project gives you a sense of satisfaction like no other. Today We have selected few easy but fun DIY arduino projects for beginners. Its very easy to do your Arduino projects at home now.

 

1. Create your own Arduino(Uno) Shield PCB board

 

The beauty of the Arduino is that it’s open source, which means you can make your own pretty easily with off-the-shelf parts. You can create this Arduino(UNO) 3 x 3 x 3 LED Cube Shield very easily using EasyEDA and when you’re done building it. You’ll have a much better understanding of exactly how the Arduino works.

 

2. DIY | RGB LED Shades Controlled By Arduino

RGB LED Shades! They're colorful, bright, hackable, and the ultimate expression of blinky awesomeness. RGB LED glasses with various animations - programmable LED show glasses with 68 full-color pixels. The LEDs can show different colors by mixing levels of red, green, and blue, just like the screen on your computer or phone. An integrated Arduino-compatible microcontroller controls the color of each pixel to display a wide range of colorful animations. Here the DIY RGB LED Shades PCB is cleverly designed and manufactured by using EasyEDA. Now, it’s possible for you to build your own RGB LED Glasses very easily and cheap.

 

3. Arduino RGB Interior Car Lighting

 

In this Arduino project guide will show you how to make an RGB interior car lighting by using the Arduino uno board. Many car enthusiasts enjoy adding extra lights or upgrading the interior bulbs to LEDs, however with the Arduino platform you can enjoy a greater level of control and detail by controlling high-powered LEDs and lighting strips. You are able to change the lighting color through an Android device (phone or tablet) by using the "Bluetooth RGB Controller" application (Dev Next Prototypes) that you can download for free from Android Play Store. Also you can find the electronic circuit schematic and board at EasyEDA and order your PCB custom Arduino based circuit.

 

4. Make Your Own Power Meter/Logger

 

The power meter/logger is combined by an Arduino, an INA219 power monitor IC, an OLED LCD and a Micro SD Card PCB. It has more functions than the popular USB Power Meter.

 

5. Add more Digital Inputs and Outputs to your Arduino

 

A lot of Dev Boards like Arduino, STM, ChipKit etc (Even micro computers like Raspberry Pi) have a limited number of Digital input and output pins, which is a serious problem for the makers while creating them projects, especially when the Dev Board should be connected to an important number of peripheric (Exemple: the 5x5x5 LED Cube where you need to control more than 100 LED). This project solved the problem perfectly, which satisfies the users desires by making a Hardware and Software solution to add more Digital I/O pins to your Arduino.

 

6. Smoke Detector using MQ2 Gas Sensor and Arduino

 

Smoke Detectors are very useful in detecting smoke or fire in buildings, and so are the important safety parameters. In this DIY Arduino project, the Smoke Detector Circuit not only sense the smoke in the air but also reads and displays the level of Smoke in the Air in PPM (parts per million). This circuit triggers the Buzzer when Smoke level becomes higher than 1000 ppm, this threshold value can be changed in the Code according to the requirement. This circuit mainly uses MQ2 Smoke/Gas sensor and Arduino to detect and calculate the level of smoke. MQ2 gas sensor is also sensible to LPG, Alcohol, and Methane etc.

 

7. DIY LED VU Meter as Arduino Shield

 

VU Meter or Volume Meter is very popular and fun project in Electronics. We can consider the Volume Meter as an Equalizer, which is present in the Music systems. In which we can see the dancing of LEDs according to the music, if music is loud then equalizer go to its peak and more LEDs will glow, and if music is low then lesser number of LEDs shall glow. Here the VU Meter was built by using Arduino and taking the audio input from 3.5 mm jack, so that you can easily provide audio input from your Mobile or Laptop using AUX cable or 3.5 mm audio jack.

 

8. Stunning RGB light effects using Arduino Nano

 

None of us could deny the fact that we would love with to play with LED’s and lighting stuffs. I love to play with LED’s and create attractive lighting effects. This project was a result of such attempt where i created a stunning RGB light effects using the popular development platform Arduino Nano. You can access this page to see the circuit, code and instruction on building this project.

 

9. Make your own Motorized Camera Slider

 

In this project, GreatSoctt shows you how to repurpose two old camera tripods in order to create a motorized camera slider. The mechanical system consist mostly of aluminium and steel which makes the slider sturdy and pretty decent looking. The electrical system consists of an Arduino Nano with LCD, rotary encoder, limit switches and stepper motor.

 

10. How to Add an IR Remote to a Speaker System

 

In consumer electronics, a remote control is a component of an electronic device such as a television set, DVD player, or other home appliance, used to operate the device wirelessly from a short distance. Remote control is primarily a convenience feature for the consumer, and can allow operation of devices that are out of convenient reach for direct operation of controls. Here shows how to create an additional circuit for speaker system in order to control it wirelessly with a homemade IR remote.

We all may have used the calculators, and if you are being involved in the scientific field then the scientific one too. What about building your own scientific calculator and showing it to your friends. You can do it by evive, it is an arduino powered embedded product. For more information you can watch this video. We have built a Scientific calculator having lots of functions like basic algebraic functions (addition, subtraction, multiplication and division), trigonometric functions, logarithmic function, square root and inverse trigonometric function.

 

An arduino sketch is made to implement this. It calculates accurately upto six decimal places and display upto four decimal place and it can be increased too.

 

 

 

 

For making this scientific calculator, you need to have this stuffs evive, keypad , breadboard and pushbuttons. After you get this stuffs, you are ready to make your own calculator. At first you should build a simple calculator, which can apply simple algebraic functions.

components calculator evive

So for this we have take help from this link. It has built this simple calculator very effectively for crystal LCD but we have tweeked it for run on ST7735 which evive uses as its screen, you can read about more components of evive from this link. Run this code snippet and see your simple code running.

 

Now, as your simple calculator is working perfectly, if not then type in comment section or email us about your problem.

 

Now we will go step by step about journey of this simple calculator to scientific calculator.

 

Firstly we made it run for the decimal numbers also as it was for whole numbers only. We added the decimal button and we did this simple stuff.

For both our input numbers the algorithm is basically the same.

Let the first number be a double named 'first'. We initialize it to be zero.

We make a Boolean 'isDecimal' and initialize it as false. This means that unless the decimal point is given as an input, the number is not a decimal.

Last, declare a float 'decimals' and set it as 10.0. We will use it for keeping a counter of our place after the decimal point.

Now if isDecimal is false, it means the number is not yet a decimal. Suppose you are storing your input number from the keypad as key.

You just need to update first=first*10+key.

But if isDecimal is true, the number is a decimal. You need to now update as

first=first+key/decimals, and decimals=decimals*10.

We keep repeating the above steps until the input for some operation is detected. Then we similarly detect the second number. Using the knowledge of the operation called, we operate the numbers and print the result when '=' is detected.

Remember to restate the values of decimals=10.0 and isDecimal=false after detection for a number is complete.You can see this code snippet too.

 

code snippet for decimal implementation

 

For other functions you need to prepare the breadboard having different pushbuttons and if you have pushbuttons of different type then use, of course it will make your calculator look more beautiful.

scientific calculator breadboard

Now, we have more buttons for the scientific functionality. We have used some colorful buttons as shown in figure. Now assign them accordingly. Take care to assign similar buttons to similar functions.

Since evive uses Arduino Mega, we have used following pins:

  • sine=Pin25
  • cosine=Pin27
  • tangent=Pin23
  • log=Pin22
  • arcsin=Pin24
  • arccos=Pin26
  • arctan=Pin14
  • root=Pin15

 

First try making the code for any one function (for example, sine function) using the inbuilt function 'sin(val)' of the arduino ide. Arduino ide also has pre-installed functions of cos, tan, inverse sin, inverse cos, inverse tan, log, square root.

You can view the following image for reference for making different functions.

3.jpg

All the codes can be downloaded from GitHub. The code is well documented and self explanatory.

 

The calculator works well!! We have also used evive's inbuilt buzzer to provide audio feedback in form of a beep while someone presses any button or switch. You can design the calculator which prints the results on the tft screen of the evive. Use different colors and sizes of text to decorate it. We can align the operants and the functions to make the appearance better.

working evive calculator

Add more functions and dig harder to make it more complex

You can check more features and techSpecs of evive to make it more advanced calculator.

evive pinout diagram techspecs
Watch the video of evive here.

To see more evive projects click here.

I've been making a video of the build-process of one of my projects.

 

Its a one-hand transmitter in the form of a glove that lets you control a quadcopter.

Anyway, just wanted to share the project, I hope you enjoy! Video link below;

ImageYoutube_nono.jpg

YouTube link:

 

 

Best regards

Josef

At last a chance to catch up with my Energy Monitor Arduino Project.

 

Here is the circuit I will build to work with my Arduino Uno via the SPI interface:

 

It is a design that was informed by discussions from this question:

 

How to Use Current and Voltage Sensors on Domestic supplies - Worldwide?

 

In the USA they use a split transformer to feed power to houses so that appliance will run on 110V or 220V. Using 220V keeps the current down for cookers and heaters.

 

The next step will be to make a prototype and set up the SPI port of the Arduino.

 

Previous Blogs:

 

1. AardEnergy – Kick Off - a new project

2. AardEnergy – Set Up Uno and Due

3. AardEnergy – Current and Voltage Transformers

4. AardEnergy – Metering Chips

I just finished a cool project with my new Cactus Micro rev2 (Arduino w/ ESP8266 WiFi built-in) and an OLED screen. My Internet of LEGO project is basically a collection of IoT, computer & electronics ideas brought to life, for my own personal amusement.

 

Check it out!

http://www.internetoflego.com/train-schedule-display-2/

Train Schedule - IoL City Train Network.png