GPS speedometer and clock
A bike or car speedometer that needs no wheel sensor: satellites do the measuring.
Shop by category
Shop all componentsDrive a servo to any angle from a phone, using either a slider value or named preset positions. A slider in a phone app sends a number as text, so the board parses it and passes it to the servo, that is app-to-hardware PWM integration in one line. The addition worth studying is the sweep: rather than jumping to the new angle, the servo steps towards it a degree at a time. Non-blocking stepping keeps the Bluetooth link responsive during the move, so a new command can interrupt one already in progress.
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
SG90 servo: turns to the angle the sketch asks for
HC-05 Bluetooth module: a serial link to your phone
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_084_smartphone_controlled_serv.inoVerify & upload in Electrolark#include <HardwareSerial.h>
#include <ESP32Servo.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
HardwareSerial bt(2); // UART2: RX on GPIO16, TX on GPIO17
Servo arm;
Adafruit_SSD1306 display(128, 64, &Wire, -1);
int currentAngle = 90;
int targetAngle = 90;
int stepDelay = 15;
unsigned long lastStep = 0;
String input = "";
String lastAction = "start";
void setTarget(int angle, String label)
{
targetAngle = constrain(angle, 0, 180);
lastAction = label;
bt.print("Moving to ");
bt.print(targetAngle);
bt.println(" degrees");
Serial.print("Target ");
Serial.println(targetAngle);
}
void handle(String line)
{
line.trim();
if (line.length() == 0) return;
String lower = line;
lower.toLowerCase();
if (lower == "min") setTarget(0, "preset min");
else if (lower == "mid") setTarget(90, "preset mid");
else if (lower == "max") setTarget(180, "preset max");
else if (lower == "slow") { stepDelay = 30; bt.println("Slow sweep"); }
else if (lower == "fast") { stepDelay = 5; bt.println("Fast sweep"); }
else if (lower == "snap") { stepDelay = 0; bt.println("Instant move"); }
else
{
int value = line.toInt();
if (value > 0 || line == "0")
{
setTarget(value, "angle " + line);
}
else
{
bt.println("Send 0-180, or min mid max slow fast snap");
}
}
}
void setup()
{
bt.begin(9600, SERIAL_8N1, 16, 17);
Serial.begin(9600);
arm.attach(26);
arm.write(currentAngle);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { while (true) { } }
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
bt.println("Send an angle 0-180 or min mid max");
}
void loop()
{
while (bt.available())
{
char c = bt.read();
if (c == '\n') { handle(input); input = ""; }
else if (c != '\r') { input = input + c; }
}
// Step towards the target without blocking
if (currentAngle != targetAngle && millis() - lastStep >= stepDelay)
{
lastStep = millis();
if (stepDelay == 0)
{
currentAngle = targetAngle;
}
else if (currentAngle < targetAngle)
{
currentAngle = currentAngle + 1;
}
else
{
currentAngle = currentAngle - 1;
}
arm.write(currentAngle);
}
display.clearDisplay();
display.setCursor(0, 0);
display.print("SERVO CONTROL");
display.setTextSize(3);
display.setCursor(0, 12);
display.print(currentAngle);
display.setTextSize(1);
display.print((char)247);
display.setCursor(70, 20);
display.print("target ");
display.print(targetAngle);
// Draw the arm position
int cx = 100;
int cy = 48;
float radians = (180 - currentAngle) * PI / 180.0;
display.drawLine(cx - 24, cy, cx + 24, cy, SSD1306_WHITE);
display.drawLine(cx, cy, cx + cos(radians) * 22, cy - sin(radians) * 22, SSD1306_WHITE);
display.setCursor(0, 40);
display.print(lastAction);
display.setCursor(0, 52);
display.print(currentAngle == targetAngle ? "At position" : "Moving...");
display.display();
}
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.
Check SDA on GPIO21 and SCL on GPIO22, power from 3V3, and that the sketch uses address 0x3C (some boards are 0x3D).
A servo can pull more current than USB gives when it starts. Keep the servo wires short and avoid moving it under load.
Pair with the HC-05 using PIN 1234 (or 0000), then connect in a Bluetooth serial terminal app. TXD goes to GPIO16 (RX2), RXD to GPIO17 (TX2).
A slider in a phone app sends a number as text, so the board parses it and passes it to the servo, that is app-to-hardware PWM integration in one line. The addition worth studying is the sweep: rather than jumping to the new angle, the servo steps towards it a degree at a time. Non-blocking stepping keeps the Bluetooth link responsive during the move, so a new command can interrupt one already in progress.
Send 45 and the servo sweeps smoothly to 45 degrees. Send max and it moves to 180. Send fast or slow to change the sweep speed, snap to jump instantly.
Yes. It is project 84 of 120 in the Geekobot Titan Kit, in level 13 (Bluetooth). 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.
7 parts: ESP32-WROOM-32 38-Pin Development Board, USB Cable, Dupont Jumper Wires (40 pcs), 0.96" OLED Display 128x64, TowerPro SG90 9g Micro Servo (180°), HC-05 6-Pin Bluetooth Serial Module with Button 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 6 steps.
No. This page has the complete, tested code (titan_kit_084_smartphone_controlled_serv.ino).
About ₹1,113 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
App-to-hardware PWM integration; Parsing a numeric value from text; Non-blocking stepped movement; Presets alongside free numeric entry.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
A bike or car speedometer that needs no wheel sensor: satellites do the measuring.
Records where you went every five seconds, ready to open on a map.
Two boards, two radios: press the button at the gate and it rings indoors.
Check temperature, humidity and pressure from any phone on your Wi-Fi.
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.