Posts with «sensor» label

Color-Coded Key Opens Doors, Opportunities

Of all the ways to open up a lock, there are some tried and true methods. Keys, combinations, RFIDs, picks, and explosives have all had their time and place, but now someone else wants to try something new. [Erik] has come up with a lock that opens when it is shown a pattern of colors.

The lock in question uses a set of color coded cards as the “keys”. When the cards are inserted in the lock, a TCS230 color sensor interprets the pattern on the cards and sends the information over to an Arduino Uno. From there, the Arduino can command the physical lock to open if the pattern is a match, although [Erik] is still waiting on the locking mechanism to arrive while he continues to prototype the device.

This is a fairly unique idea with a number of upsides. First, the code can’t be “stolen” from inside a wallet like RFID cards can. (Although if you can take a picture of the card all bets are off.) If you lose your key, you can simply print another one, and the device is able to handle multiple different keys and log the usage of each one. Additionally, no specialized equipment is needed to create the cards, unlike technologies that rely on magnetic strips. Of course, there’s always this classic way of opening doors if you’d rather go old school with your home locks.

Hack a Day 10 Mar 00:00

Optical Tach Addresses the Need for Spindle Speed Control

With CNC machines, getting the best results depends on knowing how fast your tool is moving relative to the workpiece. But entry-level CNC routers don’t often include a spindle tachometer, forcing the operator to basically guess at the speed. This DIY optical spindle tach aims to fix that, and has a few nice construction tips to boot.

The CNC router in question is the popular Sienci, and the 3D-printed brackets for the photodiode and LED are somewhat specific for that machine. But [tmbarbour] has included STL files in his exhaustively detailed write-up, so modifying them to fit another machine should be easy. The sensor hangs down just far enough to watch a reflector on one of the flats of the collet nut; we’d worry about the reflector surviving tool changes, but it’s just a piece of shiny tape that’s easily replaced.  The sensor feeds into a DIO pin on a Nano, and a small OLED display shows a digital readout along with an analog gauge. The display update speed is decent — not too laggy. Impressive build overall, and we like the idea of using a piece of PLA filament as a rivet to hold the diodes into the sensor arm.

Want to measure machine speed but don’t have a 3D printer? No worries — a 2D-printed color-shifting tach can work too.

Hack a Day 28 Jan 09:01

Flying the Friendly Skies with A Hall Effect Joystick

There are plenty of PC joysticks out there, but that didn’t stop [dizekat] from building his own. Most joysticks mechanically potentiometers or encoders to measure position. Only a few high-end models use Hall effect sensors. That’s the route [dizekat] took.

Hall effect sensors are non-contact devices which measure magnetic fields. They can be used to measure the position and orientation of a magnet. That’s exactly how [dizekat] is using a trio of sensors in his design. The core of the joystick is a universal joint from an old R/C car. The center section of the joint (called a spider) has two one millimeter thick disc magnets glued to it. The Hall sensors themselves are mounted in the universal itself. [Dizekat] used a small piece of a chopstick to hold the sensors in position while he found the zero point and glued them in. A third Hall effect sensor is used to measure a throttle stick positioned on the side of the box.

An Arduino micro reads the sensors and converts the analog signal to USB.  The Arduino Joystick Library by [Matthew Heironimus] formats the data into something a PC can understand.

While this is definitely a rough work in progress, we’re excited by how much [dizekat] has accomplished with simple hand tools and glue. You don’t need a 3D printer, laser cutter, and a CNC to pull off an awesome hack!

If you think Hall effect sensors are just for joysticks, you’d be wrong – they work as cameras for imaging magnetic fields too!

Hack a Day 18 Jan 09:00

Automated Chamber Passes Just the Right Gas

It sounds like an overly complicated method a supervillain would use to slowly and painfully eliminate enemies — a chamber with variable oxygen concentration. This automated environmental chamber isn’t for torturing suave MI6 agents, though; rather, it enables cancer research more-or-less on the cheap.

Tasked with building something to let his lab simulate the variable oxygen microenvironments found in some kinds of tumors, [RyanM415] first chose a standard lab incubator as a chamber to mix room air with bottled nitrogen. With a requirement to quickly vary the oxygen concentration from the normal 21% down to zero, he found that the large incubator took far too long to equilibrate, and so he switched to a small acrylic box. Equipped with a mixing fan, the smaller chamber quickly adjusts to setpoints, with an oxygen sensor providing feedback and controlling the gas valves via a pair of Arduinos. It’s quite a contraption, with floating ball flowmeters and stepper-actuated variable gas valves, but the results are impressive. If it weren’t for the $2000 oxygen sensor, [RyanM145] would have brought the whole project in for $500, but at least the lab can use the sensor elsewhere.

Modern biology and chemistry labs are target-rich environments for hacked instrumentation. From DIY incubators to cheap electrophoresis rigs, we’ve got you covered.

Filed under: chemistry hacks

DIY I2C Devices with ATtiny85

[Pawel] has a weather station, and its nerve-center is a Raspberry Pi. He wanted to include a light sensor but the problem is, the Pi doesn’t have a built-in ADC to read the voltage off the light-dependent resistor that he (presumably) had in his junk box. You can, of course, buy I2C ADC chips and modules, but when you’ve already got a microcontroller that has ADC peripherals on board, why bother?

[Pawel] wired up a tremendously simple circuit, downloaded some I2C slave-mode code, and added an LED for good measure. It’s all up on GitHub if you’re interested.

Bright by Day, Dark by Night!

We’re covering this because we rarely see people coding for I2C slave devices. Everyone and their mom uses I2C to connect to sensors, for which the Arduino “Wire” library or “i2c-tools” on the Pi do just fine. But what do you do when you want to make the I2C device? [Pawel]’s project makes use of TinyWireS, a slave-mode SPI and I2C library for AVR ATtiny Arduino projects.

Here, [Pawel] just wanted a light sensor. But if you’re building your own devices, the sky is the limit. What’s the most esoteric I2C sensor that you can imagine? (And is it really the case that we haven’t seen an I2C slave device hack since 2010?)

Filed under: ATtiny Hacks
Hack a Day 07 Nov 09:00

HMC5883L on the GY-80 module


In this tutorial, I will show you how to configure and extract data from the magnetometer (HMC5883L) sensor on the GY-80 10DOF module from ICStation. While there are some very good libraries on the internet which will give you full access to this sensor, I will show you what you need to know without using a library. This means that it may get a bit technical at times, but I will hold your hand along the way and provide explanations as required. I would also recommend that you watch the complete video from start to finish - as the video provides really useful information.


HMC5883L Magnetometer Datasheet:

You can find the datasheet for the HMC5883L pretty easily by searching on the internet. Here are a couple of sources:


Arduino Libraries

This tutorial does not use any external libraries.
It does use the Wire library for I2C communication.
However, there is no extra download required to access the Wire library.
If you are looking for a library specific for the HMC5883L sensor, then I would recommend one of these:

Like I said - you do not need an HMC5883L library for this tutorial. The libraries above are listed for those who wish to learn more about this particular sensor.

Arduino IDE

The Arduino IDE can be downloaded from the Arduino website. Visit the Arduino IDE download page.

I generally use the ZIP file for Windows and never seem to have any issues.
There are downloads available for all the major operating systems.



I have created a Gist for the Arduino code to configure and extract data from the HMC5883L sensor. However, I also have a GitHub repository which aims to capture the code for all of the sensors on the GY-80 module. Code for the other sensors will become available in due time. Meanwhile, have a look at the code below for the HMC5883L sensor:

This code will set all axis values to 1000 upon startup. Moving the GY-80 module around will result in a value greater or less than 1000, however, returning the sensor back to it's original position, should result in values very close to 1000 on each axis. I chose to introduce this calibration in order to avoid negative values, and I liked the fact that I could set a heading with values that were easy to remember.
The magSetting function was created to easily configure the magnetometer.
Make sure to look at the video and also the datasheet for further information about calibrating the magnetometer.
The getReadings function was created to easily retrieve the magnetometer axis data. I chose to use Single measurement mode in this tutorial.


Hooking it up:

You can communicate with any of the sensors on the GY-80 module using I2C. The HMC5883L magnetometer sensor is no different. You will need four connections between the Arduino UNO and the GY-80 module. Have a look at the diagram below for the connection diagram and table.

Fritzing diagram


Project pictures

Concluding comments

The HMC5883L sensor on the GY-80 module is quite interesting and works relatively well. There are a number of other sensors on the GY-80 module which can provide complementary positional data. At some point, I plan to come back and explain some of the other sensors on this module, but first I would like to create a real-life project using the magnetometer. So stay tuned. You may want to subscribe to my social networks or to this blog to be notified of that project when I complete it.

I would like to thank ICStation for their collaborative efforts. Their contribution was invaluable to this tutorial's existence.

If you like this page, please do me a favour and show your appreciation :

Visit my ArduinoBasics Google + page.
Follow me on Twitter by looking for ScottC @ArduinoBasics.
I can also be found on Pinterest and Instagram.
Have a look at my videos on my YouTube channel.

ScottC 06 Nov 16:20

Otto - build you own robot in two hours!

Primary image

What does it do?

Otto walks, dances, makes sounds and avoids obstacles, is completely open source, Arduino compatible, 3D printable, and with a social impact mission to create an inclusive environment for all kids.

Otto was inspired by another robot instructable BoB the BiPed and programmed using code from another open source biped robot called Zowi.


Otto's differences are in the assembled size (11cm x 7cm x12cm), cleaner integration of components and expressions.

Cost to build

$49, 00

Embedded video

Finished project



Time to build

2 hours


URL to more information


250 grams

read more

360 Degree proximity sensor

A DIY Seizure Alarm based on Arduino Micro

Chad Herbert’s son Daniel was diagnosed with Benign Rolandic Epilepsy in 2014. It’s a type of epilepsy the Epilepsy Foundation says accounts for about 15 percent of all Epilepsies in children and the good news is that most children grow out of it.

The bad news is that Daniel’s most affected by his condition at night or early morning while he sleeps. That’s why Chad invested in a sleep monitor/alarm for his bed that detects when he’s having a full tonic-clonic seizure.

At the same time though, he decided to work on a DIY version of a seizure alarm  running on Arduino Micro. The starting point was Arduino’s “Knock” example project with the sketch code originally created in 2007 by David Cuartielles and modified by Tom Igoe in 2011:

While shopping around for the exact type of monitor/alarm my wife and I wanted, I found out a few things:

  • They are hard to find. I believe the one we ended up with was manufactured by a company in Great Britain.
  • They are expensive. The one we ended up getting cost in the $400-$500 range.
  • The one we have isn’t totally cumbersome, but it’s not easy to pack up and take with you somewhere.

Figuring these things out, I decided to search for a way to build a simple seizure alam that’s both relatively inexpensive and easy to transport. I’m sure there are people out there who have children that suffer from seizures that simply cannot afford equipment such as this even though they truly need it. Thanks to the folks in the Arduino community, I was able to accomplish both things I was setting out to do.

Discover how it was made on his blog.


NeoPixel Heart Beat Display

Project Description

In this project, your heart will control a mesmerising LED sequence on a 5 metre Neopixel LED strip with a ws2812B chipset. Every heart beat will trigger a LED animation that will keep you captivated and attached to your Arduino for ages. The good thing about this project is that it is relatively easy to set up, and requires no soldering. The hardest part is downloading and installing the FastLED library into the Arduino IDE, but that in itself is not too difficult. The inspiration and idea behind this project came from Ali Murtaza, who wanted to know how to get an LED strip to pulse to his heart beat.
Have a look at the video below to see this project in action.

The Video



Parts Required:


Power Requirements

Before you start any LED strip project, the first thing you will need to think about is POWER. According to the Adafruit website, each individual NeoPixel LED can draw up to 60 milliamps at maximum brightness - white. Therefore the amount of current required for the entire strip will be way more than your Arduino can handle. If you try to power this LED strip directly from your Arduino, you run the risk of damaging not only your Arduino, but your USB port as well. The Arduino will be used to control the LED strip, but the LED strip will need to be powered by a separate power supply. The power supply you choose to use is important. It must provide the correct voltage, and must able to supply sufficient current.

Operating Voltage (5V)

The operating voltage of the NeoPixel strip is 5 volts DC. Excessive voltage will damage/destroy your NeoPixels.

Current requirements (9.0 Amps)

OpenLab recommend the use of a 5V 10A power supply. Having more Amps is OK, providing the output voltage is 5V DC. The LEDs will only draw as much current as they need. To calculate the amount of current this 5m strip can draw with all LEDs turned on at full brightness - white:

30 NeoPixel LEDs x 60mA x 5m = 9000mA = 9.0 Amps for a 5 metre strip.

Therefore a 5V 10A power supply would be able to handle the maximum current (9.0 Amps) demanded by a 5m NeoPixel strip containing a total of 150 LEDs.

Arduino Libraries and IDE

Before you start to hook up any components, upload the following sketch to the Arduino microcontroller. I am assuming that you already have the Arduino IDE installed on your computer. If not, the IDE can be downloaded from here.
The FastLED library is useful for simplifying the code for programming the NeoPixels. The latest "FastLED library" can be downloaded from here. I used FastLED library version 3.0.3 in this project.
If you have a different LED strip or your NeoPixels have a different chipset, make sure to change the relevant lines of code to accomodate your hardware. I would suggest you try out a few of the FastLED library examples before using the code below, so that you become more familiar with the library, and will be better equipped to make the necessary changes. If you have a 5 metre length of the NeoPixel 30 LED/m strip with the ws2812B chipset, then you will not have to make any modification below.


/* ================================================================================================ Project: NeoPixel Heart Beat Display Neopixel chipset: ws2812B (30 LED/m strip) Author: Scott C Created: 8th July 2015 Arduino IDE: 1.6.4 Website: Description: This sketch will display a heart beat on a 5m Neopixel LED strip. Requires a Grove Ear-clip heart rate sensor and a Neopixel strip. This project makes use of the FastLED library: You may need to modify the code below to accomodate your specific LED strip. See the FastLED library site for more details. ================================================================================================== */ //This project needs the FastLED library - link in the description. #include "FastLED.h" //The total number of LEDs being used is 150 #define NUM_LEDS 150 // The data pin for the NeoPixel strip is connected to digital Pin 6 on the Arduino #define DATA_PIN 6 //Attach the Grove Ear-clip heart rate sensor to digital pin 2 on the Arduino. #define EAR_CLIP 2 //Initialise the LED array CRGB leds[NUM_LEDS]; //Initialise the global variables used to control the LED animation int ledNum = 0; //Keep track of the LEDs boolean beated = false; //Used to identify when the heart has beated int randomR = 0; //randomR used to randomise the fade-out of the LEDs //================================================================================================ // setup() : Is used to initialise the LED strip //================================================================================================ void setup() { FastLED.addLeds<NEOPIXEL,DATA_PIN>(leds, NUM_LEDS); //Set digital pin 2 (Ear-clip heart rate sensor) as an INPUT pinMode(EAR_CLIP, INPUT);} //================================================================================================ // loop() : Take readings from the Ear-clip sensor, and display the animation on the LED strip //================================================================================================ void loop() { //If the Ear-clip sensor moves from LOW to HIGH, call the beatTriggered method if(digitalRead(EAR_CLIP)>0){ //beatTriggered() is only called if the 'beated' variable is false. //This prevents multiple triggers from the same beat. ifbeated){ beatTriggered(); } } else { beated = false; //Change the 'beated' variable to false when the Ear-clip heart rate sensor is reading LOW. } //Fade the LEDs by 1 unit/cycle, when the heart is at 'rest' (i.e. between beats) fadeLEDs(5);} //================================================================================================ // beatTriggered() : This is the LED animation sequence when the heart beats //================================================================================================ void beatTriggered(){ //Ignite 30 LEDs with a red value between 0 to 255 for(int i = 0; i<30; i++){ //The red channel is randomised to a value between 0 to 255 leds[ledNum].r=random8();; //Call the fadeLEDs method after every 3rd LED is lit. if(ledNum%3==0){ fadeLEDs(5); } //Move to the next LED ledNum++; //Make sure to move back to the beginning if the animation falls off the end of the strip if(ledNum>(NUM_LEDS-1)){ ledNum=0; } } //Ignite 20 LEDS with a blue value between 0 to 120 for(int i = 0; i<20; i++){ //The blue channel is randomised to a value between 0 to 120 leds[ledNum].b=random8(120);; //Call the fadeLEDs method after every 3rd LED is lit. if(ledNum%3==0){ fadeLEDs(5); } //Move to the next LED ledNum++; //Make sure to move back to the beginning if the animation falls off the end of the strip if(ledNum>(NUM_LEDS-1)){ ledNum=0; } } //Change the 'beated' variable to true, until the Ear-Clip sensor reads LOW. beated=true;} //================================================================================================ // fadeLEDs() : The fading effect of the LEDs when the Heart is resting (Ear-clip reads LOW) //================================================================================================ void fadeLEDs(int fadeVal){ for (int i = 0; i<NUM_LEDS; i++){ //Fade every LED by the fadeVal amount leds[i].fadeToBlackBy( fadeVal ); //Randomly re-fuel some of the LEDs that are currently lit (1% chance per cycle) //This enhances the twinkling effect. if(leds[i].r>10){ randomR = random8(100); if(randomR<1){ //Set the red channel to a value of 80 leds[i].r=80; //Increase the green channel to 20 - to add to the effect leds[i].g=20; } } };}


NeoPixel Strip connection

The NeoPixel strip is rolled up when you first get it. You will notice that there are wires on both sides of the strip. This allows you to chain LED strips together to make longer strips. The more LEDs you have, the more current you will need. Connect your Arduino and power supply to the left side of the strip, with the arrows pointing to the right. (i.e. the side with the "female" jst connector).

NeoPixel Strip Wires

There are 5 wires that come pre-attached to either side of the LED strip.

You don't have to use ALL FIVE wires, however you will need at least one of each colour: red, white & green.


Fritzing sketch

The following diagram will show you how to wire everything together
(click to enlarge)

Arduino Power considerations

Please note that the Arduino is powered by a USB cable.
If you plan to power the Arduino from your power supply, you will need to disconnect the USB cable from the Arduino FIRST, then connect a wire from the 5V line on the Power supply to the VIN pin on the Arduino. Do NOT connect the USB cable to the Arduino while the VIN wire is connected.


Large Capacitor

Adafruit also recommend the use of a large capacitor across the + and - terminals of the LED strip to "prevent the initial onrush of current from damaging the pixels". Adafruit recommends a capacitor that is 1000uF, 6.3V or higher. I used a 4700uF 16V Electrolytic Capacitor.


Resistor on Data Pin

Another recommendation from Adafruit is to place a "300 to 500 Ohm resistor" between the Arduino's data pin and the data input on the first NeoPixel to prevent voltage spikes that can damage the first pixel. I used a 330 Ohm resistor.


Grove Ear-clip heart rate sensor connection

The Grove Base shield makes it easy to connect Grove modules to the Arduino. If you have a Grove Base shield, you will need to connect the Ear-clip heart rate sensor to Digital pin 2 as per the diagram below.


Completed construction

Once you have everything connected, you can plug the USB cable into the Arduino, and turn on the LED power supply. Attach the ear-clip to your ear (or to your finger) and allow a few seconds to allow the sensor to register your pulse. The LED strip will light up with every heart beat with an animation that moves from one end of the strip to the other in just three heart beats. When the ear-clip is not connected to your ear or finger, the LEDs should remain off. However, the ear clip may "trigger" a heart beat when opening or closing the clip.
Here is a picture of all the components (fully assembled).

Concluding comments

This very affordable LED strip allows you to create amazing animations over a greater distance. I thought that having less LEDs per metre would make the animations look "jittery", but I was wrong, they look amazing. One of the good things about this strip is the amount of space between each Neopixel, allowing you to easily cut and join the strip to the size and shape you need.
This LED strip is compatible with the FastLED library, which makes for easy LED animation programming. While I used this LED strip to display my heart beat, you could just as easily use it to display the output of any other sensor attached to the Arduino.

If you like this page, please do me a favour and show your appreciation :

Visit my ArduinoBasics Google + page.
Follow me on Twitter by looking for ScottC @ArduinoBasics.
I can also be found on Pinterest and Instagram.
Have a look at my videos on my YouTube channel.


This project would not have been possible without OpenLab's collaborative effort.
Please visit their site for more cool projects.

However, if you do not have a google profile...
Feel free to share this page with your friends in any way you see fit.