L9110 Fan Motor Keyes Board

arduino fan2

The Sketch can be downloaded from my GitHub page here and includes the L9110 datasheet.

I came across this somewhat strange board advertised as a Fire Fighter with the claim that the fan was so strong it could be used to put out a flame! With a claim like that I just had to buy one, but I must confess that I have no idea what I will do with it.

The Motor Driver is an L9110 single motor driver that has two inputs INA and INB with two wire out that can drive a small DC motor. It seems to be designed to be used in toys and small robots. INA and INB are driven by logic signals, both inputs set to LOW and the motor is still, with INA HIGH and INB LOW the motor will turn one way and it will turn the other way when INA and INB are reversed.. Two other pins on this board are supplied with  5 volts (Vcc) and Gnd from the Arduino. INA and INB could be supplied with logic signals from any of the digital pins, but the motor speed would not be variable as it would run at full speed in either direction.

PWM can be used to drive the motor at variable speed in either direction and this is what the sketch here does. I found that the lowest stable speed was when the PWM was set to 80, up to the maximum of 255. Below 80 and the speed was a little erratic. I have used a KEYES momentary push button to demonstrate the motor. When the sketch first runs the motor is still. Press the button and the motor rotates, press it again and the motor stops for a brief moment then rotates in the opposite direction. On the third press the motor stops. The short delay when changing direction allows the motor to slow right down first.

The Circuit::l9110 arduino

Circuit diagram

The Sketch::

* Fan Driver using L9110 Motor Driver
* The L9110 Motor Diver is a simple driver designed for
* toys and robots. It has two inputs INA and INB
* and two outputs to drive a simple DC Motor.
* The direction of motor spin can be changed and the speed
* can be controlled using PWM
* The device described here is the Keyes Fan Board with
* 4 connections
* Connections:
* INA to Arduino PIN 5
* INB to Arduino PIN 6
* Vcc to Arduino 5 volts
* GND to Arduino GND
* Push Button:
* (the output went LOW on pressing on my unit)
* Gnd to Arduino Gnd
* Vcc to Arduino 5 volts
* S to Adduino PIN 7
const int INA = 6;
const int INB = 5;
const int pushButton = 7;
const int ledPin = 13; // onboard LED
int action = 0; // 0 = Stop, 1 = Forward, 2 = Reverse

byte speed = 80; // change this to alter speed 0 - 255 although 80 is the minimum for reliable operation

void setup()
pinMode(pushButton, INPUT);
pinMode(ledPin, OUTPUT); // onboard LED
Serial.begin(9600); // for debug

void loop()
if (digitalRead(pushButton) == LOW){ // see if button has been pressed
digitalWrite(ledPin, HIGH); // turn on LED
action = action + 1; // increment action
if(action > 2){
action = 0; // keep action in range
if (action > 0){
digitalWrite(ledPin, HIGH); // Turn OFF LED if motor stopped
delay(100); // short delay to make direction change easier for motor
else digitalWrite(ledPin, LOW); // turn onboard LED OFF
delay(800); // simple switch debounce

switch (action){
case 0:
Serial.println("Stop Fan:");

case 1:
Serial.println("Fan Forwards:");

case 2:
Serial.println("Fan Reverse:");

void reverse(){
void forward(){

void stopFan(){


Clap Switch Sound Sensor DIY Kit NeoPixel Ring Display


The sketch for this project can be downloaded from my GitHub page here.

This project uses the Clap Switch described in my blog  here and shows how it can be used to step through the display modes in the Adafruit sketch included with the NeoPixel library. I am using a 16 LED NeoPixel ring in this project, if you are using a different number then the number of LEDs needs to be adjusted in the sketch. PIXEL_COUNT is the number of LEDs and PIXEL_PIN is the Arduino pin number connected to DI on the neoPixel ring (in this case Digital pin 5).

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

You need to download and install the Adafruit NeoPixel library from here, I have uploaded my modified version of the Adafruit buttoncycler sketch on my GitHub page here. The original Adafruit sketch used a push switch to change the display, I modified the sketch to use the output from the Clap Switch. With the sketch (clapSwitch_buttoncycler.ino) loaded the NeoPixel display should be OFF. Clap your hands and the LED on the clap switch should go OFF. The NeoPixel ring will start flashing in one of nine patterns, it will continue until you clap again. The ring will stop at the end of the current cycle (which in the case of some of the rainbow patterns may take a few seconds). Clap to start the display running again.

The Sketch::

The sketch is modified from the Adafruit buttoncycler sketch, the code to operate from a push button has been removed and new code to monitor the clap switch has been added. My original code had to be modified slightly as it required two Claps to switch the display ON or OFF. The modified code uses one Clap to start the display and one to stop. The variable trigger is flipped between TRUE and FALSE, with the red LED on the clap switch showing the state (ON = trigger TRUE). The value is checked at the start of the main loop, however, with some of the displays that run for some time, trigger will not be checked until the current display has finished. This will result in a delay before the display is stopped.

The clap switch output turns the on-board LED, on pin 13, ON and OFF to indicate when the variable trigger has been read.



Please note that for illustration purposes the NeoPixel ring is shown as being powered by the Arduino. For normal use the NeoPixel ring should be supplied from an external stabilised 5 volt supply.

Clap Switch Sound Sensor DIY Kit

clap switch

This kit is available on eBay for less than £2 and I purchased mine from here. The PCB is of reasonable quality and screen printed with all the component values that make it easy to build this project. Several components need to be connected in one direction, the two electrolytic capacitors easy to align as the negative is shown shaded, the two small diodes have a black band on one end and both are aligned in the same direction. The symbol for a diode is printed on the PCB and the bar on the symbol represents the black band on the component. There are four transistors and they should be inserted on the board so that the flat on the transistor aligns with the flat printed on the board. The microphone position shows a + and a -, but no markings were printed on my microphone. However, the pins are offset and the microphone can only be fitted one way so that it fits inside the printed circle. The last component the needs fitting correctly is the LED, this has one leg longer than the other and, more importantly, a flat on one side. The LED is aligned so that it faces to the edge of the PCB, if it is fitted the wrong way round the completed board will not work.

All the remaining components can be fitted either way round, resistors need to have their their leads bent close to the body. There are two values of capacitor, 0.1mfd and 0.01mfd (marked as 104 and 103 respectively), fit the 103 first, then fit 104 capacitors to avoid fitting the 103 in the wrong place. The power socket should obviously be fitted with the open end facing the edge of the board. I soldered a two pin plug to the supplied power lead so that it could be plugged into the Arduino 5volt and Gnd.

Once everything is soldered you will probably find a small printed rectangle alongside the LED with two holes, mine was printed with Link. At first I thought I had a missing component or a small wire link was required, but checking the copper side of the PCB showed one of the solder pads was connected to the 5volt track and the other solder pad was on a copper track alongside the 5volt track. I suspected that this may be the output from the Clap Switch and decided to fit a two pin male header. However, the hole spacing was not exactly 0.1 inches and I had to very carefully enlarge the holes. Be very careful not to destroy the solder pads or push the off the board if you do this! The alternative is to simply solder two leads into these holes, it’s up to you.

The board is very compact and the solder pads vey close together so be careful not to short pads. I use a stiff brush and alcohol to clean all the flux etc from the board after soldering. Use a magnifying glass to check for dry joints and shorts. Once you are happy all is well you can connect to a 5 volt supply or use the 5volt and Gnd pins on an Arduino. The LED will light up (it did on mine, but this may be random). Clap your hands about 1 foot from the microphone and the LED will change state. Clap again and it will change state again.

I suspect, although I have not checked, that the circuit is a microphone pre amplifier with its output fed into a bistable flip flop similar to this one

Which is why the output remains in one state and need another trigger to switch to the other state. I used a multimeter connected to the two pins I had soldered alongside the LED, when the LED was lit it showed about 4.8volts and when the LED was off it showed just under 1 volt. The pin closest to the edge of the board is always 5 volts, so I ignored that on, the other pin will be equivalent to HIGH when the LED is not lit and LOW when lit.

I use the term Clap Switch Output pin to identify the pin circled in red below. The pin above this is connected to the 5volt PCB track and can be ignored. It is important that the Gnd of the Clap switch is connected to the Arduino Gnd, but if it is powered from the Arduino this will happen automatically.

I did try using the output from the Clap Switch to trigger an interrupt on the Arduino pin 2 and this worked well in a quiet room, however the results were erratic with background noise. There is no rush to read the state of the switch, simply read the state at a convenient point in your sketch. The sketch below shows how this can be done, it reads the voltage on pin A0 and sets the variable trigger to False if it is above 2 volts and True if it is below 2 volts. The onboard LED on pin 13 is the lit if  trigger is True.

Clap Switch Simple Control
Chris Rouse
May 2016


Vcc to Arduino 5 volts
Gnd to Arduino Gnd
Output to Arduino Analog pin 0

const byte ledPin = 13;
boolean trigger = false; // used to show clap output ON
int triggerLevel = 100; // change this if background noise is high
int outputReading; // voltage output from Clap Switch

void setup() {
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW); // turn LED OFF
void loop() {
checkSwitch(); // see if the switch has been triggered
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin, LOW);

// put the rest of your program here

void checkSwitch() {
outputReading = analogRead(14);
if(outputReading > triggerLevel){
trigger = false;
trigger = true;

Arduino Crash Sensor

crash sensor

This sensor is simply a micro switch. When the small lever is pushed in an on board LED lights and the output goes LOW. The following sketch lights the LED on the Arduino when the lever is pressed.

// Crash sensor
int ledPin = 13;
int inPin = 8;
int earthPin = 6;
int vccPin = 7;
int valueCrash = 1;

void setup() {
pinMode(ledPin, OUTPUT);
pinMode(inPin, INPUT_PULLUP);
pinMode(earthPin, OUTPUT);
pinMode(vccPin, OUTPUT);
digitalWrite(earthPin, LOW); // provide 0 volts for Gnd
digitalWrite(vccPin, HIGH); // provide +5 volts for Vcc


void loop() {
valueCrash = digitalRead(inPin); // read the state of the crash sensor
digitalWrite(ledPin, !valueCrash); // light LED if switch closed



5×4 20 Key Matrix Keyboard Electronic Lock

20 key keypad

The code for this project can be found on my GitHub page here.

See also the post describing the simple program to read this keypad here.

This project illustrates the use of the 20 key matrix keyboard shown in an earlier blog here. These keyboards can be obtained on eBay, often for £1 but don’t lend themselves to being used for calculators. However, they make an ideal data entry pad for something like an electronic lock.

I have chosen not to include any electronics such as relays or servo motors as these can easily be added to suit the individual needs. There are two locks, each with their own password, selected by pressing either F1 or F2. The password is a four digit number, although it can be increased by changing the variable maxNumber. Other non digit keys (except for the arrow keys) have various functions. Ent is used to lock the current Lock. Esc will abort code entry in the case that a wrong digit was entered (this could be useful if the number of incorrect code entries is limited before no further entries were allowed). # will show the current state of both locks and finally * will lock both locks at once, regardless of their current state.

The output is sent to the Serial Monitor and the on board LED is lit if the current Lock is closed.

The circuit:

The connection diagram is shown below, the keyboard uses nine digital pins and pin 13 is used to show the status of the current lock. This leaves two digital pins and the four Analog pins to operate relays, servo motors etc. Connection data is provided in the sketch.