Introduction: Wink Detector

About: 55+ years in electronics, computers, and teaching ... now retired.

This instructable explains how to make a “wink-detector” from a modified AD8232 ECG (electrocardiogram) sensor, an LM324-N quad op-amp, an Arduino Uno R3, and a home-made head-band.

The detector has two outputs ... one for when you wink your left-eye ... and one for when you wink your right.

Normal blinks, which involve both eyes, are ignored.

Applications for this circuit include:

  • game interfaces
  • assistive technology

Few tools are required ... just a soldering iron and a sharp knife.

The sensor modifications, which can be reversed, require that you:

  • cut two tracks
  • add two solder bridges/shorts
  • add a short wire link

The estimated cost of components is $15.00

Images

  • The cover photo shows a closeup view of the wink-detector
  • Photo 2 shows the approximate position for the headband.
  • The video shows the wink-detector in operation. Three successive winks are made with each eye.

Step 1: Parts List

The following parts were obtained from https://www.aliexpress.com/

  • 1 only AD8232 ECG heart monitor module
  • 1 only Arduino Uno R3

The following parts were obtained locally:

  • 1 only LM324 quad-op-amp
  • 1 only 220K ohm resistor 1/8 watt
  • 2 only 120K ohm resistors 1/8 watt
  • 1 only 15K ohm resistor 1/8 watt
  • 2 only 10K ohm resistors 1/8 watt
  • 1 only 1200 ohm resistor 1/8 watt

Misc items already on hand:

  • breadboard
  • stranded copper wire
  • solder

The estimated cost of components is $15

Step 2: Circuit

The “wink detector” circuit diagram is shown in photo 1

The circuit comprises a modified AD8232 ECG heart sensor module, an LM324 quad-op-amp, an Arduino Uno R3, a few resistors , and two LEDs.

The output waveform from the AD8232 hovers about 1.5 volts DC.

When the left-eye winks the AD8232 output wave form rises towards 3.3 volts. When the waveform exceeds 2.8 volts the left-wink comparator output changes from zero to 5 volts as shown in photo 2.

When the right-eye winks the AD8232 output wave form falls towards zero volts. When the waveform falls below 0.2 volts the right-wink comparator output changes from zero to 5 volts as shown in photo 3.

Normal blinks have no effect on the output as they are the equivalent of two simulataneous winks and it’s not possible for the AD8232 output to go in two opposite directions at the same time.

The AD8232 is supplied with a set of gel-coated ECG pads and leads. After a few uses the pads tend to fall off. To counter this I attached some tinned-steel pads to a headband made from an old lanyard and Velcro. Details on how to construct this head-band are described elsewhere in this article.

Step 3: AD8232 Circuit Modifications

An unmodified circuit board is shown in photo 1

When used as a heart monitor the ECG leads are connected as follows:

  • Right arm is connected to RA
  • Left arm is connected to LA
  • Right leg is connected to RL

A modified circuit board is shown in photo 2

After the modifications the leads become:

  • Right eyebrow is connected to RA
  • Left eyebrow is connected to LA
  • Forehead is connected to RL

The original circuit

A simplified block diagram of the original heart monitor is shown in photo 3.

This diagram was created by matching the component values in the Sparkfun “Heart Monitor” schematic [1] to the AD8232 “Functional Block Diagram” [2]

When used as a heart monitor, both inputs to the AD8232 instrumentation amplifier are tied to the 3.3 volt supply rail via 10M resistors. The instrumentation amplifier, however, can’t operate unless the two input leads are around mid-rail potential.

Mid-rail potential is obtained by injecting a tiny (10uA) current from the RLD (right leg drive) lead into your leg. We have effectively created a voltage divider using your body as one of the resistors.

The actual purpose of the RLD lead is explained in the AD8232 data sheet ... I’m just looking at it from a different viewpoint.

The modified circuit

A block schematic of the circuit modifications is shown in photo 3.

Instead of looking for heart beats, the wink detector is looking for differences in electrical potential. As such it needs to be fully operational at all times ... both inputs of the instrumentation amplifier must be tied to a mid-rail potential such as Vref (1.5 volts)

This is achieved by cutting the track that connects both 10M resistors to the 3.3 volt supply and joining the cut end to Vref by means of a small wire link. Both inputs of the instrumentation amplifier are now at mid-rail potential which means the AD8232 output hovers about 1.5 volts DC.

We also don’t need the RLD lead ... let’s use this lead to improve the CMRR (common mode rejection ratio) of the system by raising your body to midrail potential. This is achieved by cutting the track to the AD8232 RLD pin and joining the cut end to Vref.

The AD8232 data sheet recommends that the RLD and RLDF (right leg drive feedback) pins be shorted when using a two-lead circuit. This is achieved by shorting the capacitor joining these two pins.

References

[1]

https://cdn.sparkfun.com/datasheets/Sensors/Biomet...

[2]

https://www.analog.com/media/en/technical-document...

Step 4: The Headband

The headband was fashioned from an old lanyard, a length of Velcro, and some Velcro hooks. Construction details are shown in photos 1..4

The pads are made from thin tin plate ... I used the bottom of an old paint can ... and are attached to the lanyard by narrow tabs cut from the same tin plate. This allows the pads to slide around the headband.

Dull the edges of the metal pads with a file and lightly sand the contact surfaces. Solder the heart monitor leads to the exposed metal tabs.

It is important that the pads make good skin contact ... medical contact gel is recommended but I have found that hand moisturiser also works.

The pad size is not critical ... I have since reduced the width while experimenting with closer pad-spacing ... halving the size made no difference.

Step 5: Software

Instructions

Upload the attached file “wink_detector_4.ino” to your Arduino and run.

Notes

The code is remarkably simple ... it simply polls each of the two wink-detector outputs and flashes the appropriate LED whenever a comparator changes state.

But there is a catch ... strong winks can cause the opposite LED to flash.

The top trace in photo 1 shows the AD8232 output dipping down to zero volts following a strong left-eye wink. The right-eye comparator (lower trace) sees this as a right-wink and generates a false output.

Photo 2 shows both comparator outputs for a strong left-wink. The right-comparator is still generating a false output 800mS after the left-wink starts.

A software solution is used to get around this ... the first detector to see a wink disables the other detector for 1 second. This period is adjustable in the code header,

Step 6: Summary

This instructable explains how to convert a Sparkfun AD8232 “Heart Monitor” to a “Wink Detector”.

Construction details for an adjustable head-band are also provided.

The Arduino code eliminates false triggers due to overshoot from the AD8232 output in the presence of strong winks.

Applications for this circuit include:

  • game interfaces
  • assistive technology

The estimated cost of components is $15.00

  Click here   to view my other instructables.