Automated 7 Segment mechanical counter

Automated 7 Segment mechanical counter with servo
22
80
0
1212
updated July 2, 2024

Description

PDF

Components

Standard pieces

You will need to print the standard part of the 7 Segment Mechanical Counter.
You also can use tigh tolerences part from my previous remix.

Custom pieces

You need the backplate and the push action from this model. 
Tips: Print the push action on it's side with tupport to have smooth surfaces.

Servo

This model is optimized for a mg995 servo

Servo horn

I've used this horn for the servo.

Microcontroller

The code that follow is for an ESP32 but you are free to use what you want.

Code

I've based the servo control from this video.
 

First version, going through all the number

// Import ESP32Servo library, don't forget to install it. https://madhephaestus.github.io/ESP32Servo/annotated.html
#include <ESP32Servo.h>

// Initiate the variables
Servo myServo;
int count = 0;
int wantedCount = 0;

// Setup servo and serial communication
void setup() {
  myServo.attach(13);
  Serial.begin(115200);
}

void loop() {
  nextDigit();
}

// Function making the servo go down, then go up
void nextDigit() {
  myServo.write(100);
  delay(500);
  myServo.write(170);
  delay(500);
}

Second version, select a specific number to go to

// Import ESP32Servo library, don't forget to install it. https://madhephaestus.github.io/ESP32Servo/annotated.html
#include <ESP32Servo.h>

// Initiate the variables
Servo myServo;
int count = 0;
int wantedCount = 0;

// Setup servo and serial communication
void setup() {
  myServo.attach(13);
  Serial.begin(115200);
}

void loop() {
  // Read the integer value from serial input, make sure to input a number between 0 and 9
  if (Serial.available() > 0) {
    wantedCount = Serial.parseInt();
  }
  
  // Move the servo until the count matches the wantedCount
  while (count != wantedCount) {
    // Trigger the servo
    nextDigit();
    count++;

    // Loop back to 0 when hiting 10
    if (count == 10) {
      count = 0;
    }
    Serial.println("wanted: " + String(wantedCount));
    Serial.println("current: " + String(count));
  }
}

// Function making the servo go down, then go up
void nextDigit() {
  myServo.write(100);
  delay(500);
  myServo.write(170);
  delay(500);
}

Tags



Model origin

The author remixed this model.

Differences of the remix compared to the original

I've modified the back plate in order to be able to attach a mg995 servo.
I've also added an arm to the push action in order for the servo to push on it

License


Highlighted models from creator

View more