Touchless hand sanitiser dispenser
Hold your hand under it and a metal-gear servo presses the pump for you.
Shop by category
Shop all componentsUse the servo to point at one of several labelled categories rather than a continuous scale. A continuous meter can rest anywhere; a category pointer must land exactly on one of five positions. The angles are stored in an array, so choosing a category is choosing an index, categorical physical indexing. Because the pointer should not hover between two labels while a reading sits on a boundary, the sketch also requires the new category to hold for a moment before the servo moves, which stops a twitching needle.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
Every part for this build comes in the Geekobot Titan Kit box, a Geekobot exclusive, together with the parts for all 120 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
ESP32 DevKit V1 (38-pin): the brain of every Titan Kit project, with Wi-Fi and Bluetooth
Male-to-female and female-to-female leads for the modules
DHT11 temperature and humidity sensor
SG90 servo: turns to the angle the sketch asks for
ESP32 expansion board from the kit: every GPIO has its own S, V, G header
Follow the colours: red is power, dark grey is ground, blue is a signal.
titan_kit_102_servo_controlled_pointer.inoVerify & upload in Electrolark#include <ESP32Servo.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>
#define DHTPIN 14
#define DHTTYPE DHT11
#define CATEGORIES 5
Servo pointer;
DHT dht(DHTPIN, DHTTYPE);
Adafruit_SSD1306 display(128, 64, &Wire, -1);
int stepButton = 12;
int buzzer = 33;
// One fixed angle per category
int categoryAngle[CATEGORIES] = {20, 55, 90, 125, 160};
const char* categoryName[CATEGORIES] =
{
"COLD", "COOL", "IDEAL", "WARM", "HOT"
};
float upperLimit[CATEGORIES] = {18, 22, 27, 31, 99};
int category = 2;
int candidate = 2;
unsigned long candidateSince = 0;
unsigned long settleTime = 1500;
bool manualMode = false;
float temp = 0;
unsigned long lastRead = 0;
int categoryFor(float t)
{
for (int i = 0; i < CATEGORIES; i++)
{
if (t < upperLimit[i]) return i;
}
return CATEGORIES - 1;
}
void moveTo(int index)
{
pointer.write(categoryAngle[index]);
tone(buzzer, 1200, 80);
Serial.print("Pointing at ");
Serial.print(categoryName[index]);
Serial.print(" (");
Serial.print(categoryAngle[index]);
Serial.println(" degrees)");
}
void setup()
{
pinMode(stepButton, INPUT_PULLUP);
pinMode(buzzer, OUTPUT);
pointer.attach(26);
pointer.write(categoryAngle[category]);
Serial.begin(9600);
dht.begin();
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { while (true) { } }
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
}
void loop()
{
if (digitalRead(stepButton) == LOW)
{
manualMode = true;
category = (category + 1) % CATEGORIES;
candidate = category;
moveTo(category);
delay(350);
}
if (millis() - lastRead > 2000)
{
lastRead = millis();
float t = dht.readTemperature();
if (!isnan(t)) temp = t;
if (!manualMode)
{
int wanted = categoryFor(temp);
if (wanted != candidate)
{
candidate = wanted;
candidateSince = millis();
}
else if (candidate != category && millis() - candidateSince > settleTime)
{
category = candidate;
moveTo(category);
}
}
}
display.clearDisplay();
display.setCursor(0, 0);
display.print("POINTER DISPLAY");
display.setCursor(84, 0);
display.print(manualMode ? "MANUAL" : "AUTO");
display.setTextSize(2);
display.setCursor(0, 14);
display.print(categoryName[category]);
display.setTextSize(1);
display.setCursor(0, 34);
display.print("Temp ");
display.print(temp, 1);
display.print("C arm ");
display.print(categoryAngle[category]);
display.print((char)247);
// Show all five positions with the active one filled
for (int i = 0; i < CATEGORIES; i++)
{
int x = i * 25 + 3;
display.drawRect(x, 44, 21, 12, SSD1306_WHITE);
if (i == category)
{
display.fillRect(x + 2, 46, 17, 8, SSD1306_WHITE);
}
}
display.setCursor(0, 58);
display.print("D3 steps manually");
display.display();
delay(60);
}
Use a micro-USB data cable (some cables only charge), install the CP210x or CH340 driver if no port appears, pick Tools > Board > ESP32 Dev Module and hold the BOOT button on the board until the upload starts.
The sketch uses INPUT_PULLUP, so one leg goes to the GPIO and the other to GND. Use two legs on opposite sides of the button.
This project needs the passive buzzer (the one that plays notes), not the active one.
Check SDA on GPIO21 and SCL on GPIO22, power from 3V3, and that the sketch uses address 0x3C (some boards are 0x3D).
A continuous meter can rest anywhere; a category pointer must land exactly on one of five positions. The angles are stored in an array, so choosing a category is choosing an index, categorical physical indexing. Because the pointer should not hover between two labels while a reading sits on a boundary, the sketch also requires the new category to hold for a moment before the servo moves, which stops a twitching needle.
The arm points at IDEAL at room temperature. Warm the sensor by hand and after a moment the arm swings to WARM. Five boxes on screen show which position the arm is in.
Yes. It is project 102 of 120 in the Geekobot Titan Kit, in level 15 (Actuators). Every part on the list comes in the kit box, and you can also buy the parts one by one from the list above.
No. Every Titan Kit project is wired on the ESP32 expansion board and the breadboard with jumper wires.
10 parts: ESP32-WROOM-32 38-Pin Development Board, USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), Tactile Push Button Switch, Buzzer Module 3.3–5V, 0.96" OLED Display 128x64, Generic DHT11 Digital Temperature & Humidity Sensor Module, TowerPro SG90 9g Micro Servo (180°) and ESP32 38-Pin Expansion Board. On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 45 minutes. The build on this page has 8 steps.
No. This page has the complete, tested code (titan_kit_102_servo_controlled_pointer.ino).
About ₹1,007 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Categorical physical indexing; Fixed positions instead of a continuous sweep; Settle time to stop boundary flapping; Manual override alongside automatic control.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
Hold your hand under it and a metal-gear servo presses the pump for you.
Wave your hand and the lid lifts by itself, then closes after three seconds.
Your first motion project: turn the knob and the servo follows.
Dial in an exact servo angle, 2° per click, shown on screen.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.