A chronometer is a timekeeping device used to measure the amount of time elapsed between its activation and deactivation. It typically consists of a digital or analog display and buttons to start, stop, and reset the timer. chronometer functions are commonly used in sports, fitness activities, scientific experiments, and various timed events where precise timing is essential.
Using a chronometer with an Arduino Uno is a fun and educational project. You can create a simple chronometer using the Arduino Uno board and some additional components like buttons and SSD1306 display.
The operation of the chronometer controlled by the Arduino UNO with SSD1306 display and push buttons can be described as follows:
Initial Startup: When you power the Arduino UNO, the timer begins to display Press START on the SSD1306 display.
Start Button: By pressing the Start button, the chronometer starts measuring the time from 00:00 until you press the Stop button.
When the chronometer is running, the SSD1306 display shows the elapsed time in minutes and seconds, for example, 00:15 (15 seconds elapsed), 01:30 (1 minute and 30 seconds), etc.
Pressing the stop button again causes the chronometer to freeze, recording the time elapsed up to that point, without setting it to zero.
Reset Button: By pressing the reset button, the timer returns to 00:00, thereby resetting the elapsed time to zero, regardless of its previous state (running or stopped).
This operation allows you to control the chronometer using the push buttons: start to start measuring time, stop to freeze the current time and reset to reset the chronometer to zero. The SSD1306 display shows real-time elapsed time in minutes:seconds format while the chronometer is running.
To build a chronometer controlled by an Arduino Uno board, you'll need several components to create the necessary functionalities. Here's a list of components required:
Arduino Uno Board:
The Arduino Uno board is a microcontroller board based on the ATmega328P microcontroller. It's one of the most popular and widely used boards in the Arduino family due to its simplicity and versatility.
It is the central control unit for your project.
SSD1306 Display:
The SSD1306 display is a small OLED (Organic Light Emitting Diode) screen known for its use in various electronic projects. It's commonly employed for displaying information in DIY electronics, such as displaying text, graphics, or icons. The SSD1306 usually comes in resolutions like 128x64 pixels or 128x32 pixels and can be controlled by microcontrollers like Arduino.
Pushbuttons:
These will serve as controls for starting, stopping, and resetting the chronometer.
Resistors:
You might need resistors (usually around 10k ohms) for pull-up or pull-down purposes when interfacing the pushbuttons to prevent floating values.
Breadboard:
A breadboard is a useful tool for creating temporary electronic circuits. It allows you to connect components without soldering.
Jumper Wires:
For making temporary connections and wiring between components.
These are the basic components required to build a chronometer using an Arduino Uno. The specific values and quantities might vary based on your design preferences and the exact functionality you wish to implement.
Mounting the Arduino Uno board with SSD1306 display and push buttons involves physically setting up these components on a breadboard or a prototyping board and wiring them together. Here's a step-by-step guide to mounting these components:
Mount the SSD1306 Display:
- Connect the GND pin of the SSD1306 display to the GND pin of the Arduino UNO board
- Connect the VCC pin of the SSD1306 display to the 5V pin of the Arduino UNO board
- Connect the SDA pin of the SSD1306 display to the A4 pin of the Arduino UNO board
- Connect the SCL pin of the SSD1306 display to the A5 pin of the Arduino UNO board
Connect Start Push Button:
- Put a resistor (10 kohm) between one of the legs of the push button and the GND pin of the Arduino UNO
- Connect the same pin of the push button to pin 2 of the Arduino UNO board
- Connect another pin of the push button to the 5V pin of the Arduino UNO board
Connect Reset Push Button:
- Put a resistor (10 kohm) between one of the legs of the push button and the GND pin of the Arduino UNO
- Connect the same pin of the push button to pin 3 of the Arduino UNO board
- Connect another pin of the push button to the 5V pin of the Arduino UNO board
To create a chronometer display on SSD1306 with Arduino Uno, you'll need the necessary libraries installed in your Arduino IDE to control the SSD1306 display. The most common library for this purpose is the "Adafruit_SSD1306" library. Ensure you've installed it before proceeding.
Here's an example code that sets up a simple chronometer on SSD1306 display with start, stop, and reset functionalities using push buttons:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
#include <Adafruit_SSD1306.h> //OLED define #define SCREEN_WIDTH 128 // OLED display width, in pixels #define SCREEN_HEIGHT 64 // OLED display height, in pixels // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); const int start_pause_pin = 2, resetpin = 3; String stopwatch = "stop", start_pause = "low"; long start_time = 0, seconds = 0; void setup() { Serial.begin(9600); pinMode(start_pause_pin, INPUT); pinMode(resetpin, INPUT); Serial.begin(9600); //For OLED I2C if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64 Serial.println(F("SSD1306 allocation failed")); for(;;); } display.display(); //Display logo delay(1000); display.clearDisplay(); display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(0, 0); display.print("Hello!"); display.display(); delay(1000); display.setCursor(0, 20); display.print("Start"); display.setCursor(0, 40); display.print("chrono"); //display.print(""); display.display(); } void loop() { display.clearDisplay(); if (stopwatch == "run") { display.print(""); display.setCursor(0, 0); display.print("Chrono"); display.setCursor(0, 20); seconds = (millis() - start_time) / 1000; long centisecond = ((millis() - start_time) % 1000) % 100; //display the timer on the SSD1306 display display.setCursor(0, 20); display.print(seconds); display.setCursor(20, 20); display.print(":"); display.setCursor(30, 20); display.print(centisecond); display.display(); Serial.println(start_time); Serial.println(millis()); } if (digitalRead(resetpin) == HIGH) { //Reset stopwatch stopwatch = "stop"; start_time = 0; display.setCursor(0, 0); display.print("Press"); display.setCursor(0, 20); display.print("Start"); display.display(); } if (digitalRead(start_pause_pin) == HIGH && stopwatch == "stop") { //Start stopwatch start_time = millis(); display.print(""); stopwatch = "run"; start_pause = "high"; } else if (digitalRead(start_pause_pin) == HIGH && stopwatch == "run" && start_pause == "low") { //Pause stopwatch stopwatch = "pause"; start_pause = "high"; } else if (digitalRead(start_pause_pin) == HIGH && stopwatch == "pause" && start_pause == "low") { //Resume stopwatch start_time = millis() - (seconds * 1000); stopwatch = "run"; start_pause = "high"; display.print(""); } else if (digitalRead(start_pause_pin) == LOW) { start_pause = "low"; } delay(10); } |
Upload this code to your Arduino Uno and observe the SSD1306 display to see the chronometer functionality when you press the buttons. Adjust the connections if needed and ensure you've set up the I2C address correctly for your display.
Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.
Zaouiet Kontech-Jemmel-Monastir-Tunisia
+216 92 886 231
medaliprof@gmail.com
Robotic site created by MedAli-Teacher info