The Beginning
A couple of months ago, my father bought my sister and me an Arduino Microcontroller Starter Kit. I’m really excited to learn software coding in Arduino platform. We started this journey by making simple circuits and decided to design a stopwatch using the Arduino starter kit.
The Stopwatch Project
Arduino
Arduino is a hardware and software company that manufactures microcontroller-based circuits and kits. These circuits can be used to make useful electronics projects. Arduino kits help us to start learning easily the coding and building electronics circuit. For this project, we used the Arduino UNO starter kit K000007 that comes with the microcontroller development board and many electronics components like resistors, motors, LCD display…
This stopwatch is built using the electronics components that came with the Arduino UNO kit including a Liquid Crystal Display (LCD). I learned how to program the microcontroller to display numbers and alphabets on the LCD by reading the Arduino Projects Book.
Arduino IDE
Arduino IDE has to be installed in a computer for writing the software code. The IDE looks like a text editor for writing the software code. Arduino IDE can compile the code — converting the text of the code into microcontroller readable format, it can point out syntax errors and it can download the code from the computer to the Arduino UNO board via a USB cable.
The Circuit Schematics Diagram
This schematics diagram given here shows the connections between Arduino UNO board, LCD and the piezo buzzer. Please note that the blue-coloured was not assembled in the final version.
I connected the LCD pins to the Breadboard and Arduino board with the reference from the schematics diagram and using jumper wires.
Continuity of all connections were double checked using the multimeter. The circuit draws electric power from the computer via the same USB cable that helps us to download software code from Arduino IDE to Arduino UNO board.
Coding
Writing the code for the stopwatch was very challenging for me. The heart of the project is a variable representing seconds that increments after a delay of 1000 milliseconds (one second). The stopwatch was made to read up to 23 hours, 59 minutes and 59 seconds. The code uses variables for the display of unit place and tenth place of hours, minutes and seconds on the LCD.
Strangely, the code was not functioning properly and the LCD started counting the wrong way after a specific period of elapsed time. Debugging the code took a couple of hours and my father decided that we need to find a simulator tool for Arduino. After a quick search in the internet, we found an excellent free simulator from Autodesk, known popularly as TinkerCAD. It runs in our internet browser and no installation is required.
Autodesk TinkerCAD Simulator
TinkerCAD can also be used to make 3D designs which can be printed out using a 3D Printer. This circuit simulator has a lot of electronics components, micro-controller systems and Arduino boards. This makes it possible to build an electronics system without buying or assembling the physical hardware.
After creating an account in TinkerCAD, there is a circuit builder page where we can drag and drop electronic components from a library onto an on-screen breadboard. We can also connect the components by ‘drawing’ wires between them.
The library includes many Arduino boards including our Arduino UNO. We can copy-paste the already-written code from Arduino IDE to TinerCAD for debugging. There is a start simulation button and when we click on it, the code starts running and the Arduino circuit comes alive on the screen.
We can add ‘breakpoints’ in the code by clicking on the code line numbers. When the control reaches a breakpoint, it pauses the code execution. There is a provision to ‘step over’ – it means, executing just one line of code and pause there. By hovering the mouse cursor on the variables declared in the code, we can see the values stored by them. This helps us to find the software bugs faster and make the code error-free by editing.
Soon I found the mistake — the variables of the hours, minutes and seconds were declared wrongly when their values were reset to zero. Once that was corrected, the code started running smoothly in the simulator.
Now the finalized code from TinkerCAD is copied back to Arduino IDE. It is compiled and downloaded into the Arduino board. Now the stopwatch started working beautifully, as intended!
Conclusion
I’m very happy and excited to learn coding that helped me to control an electronics circuit to do an intended process. This experience has given me a unique perspective of the digital world around us.
Now I’m very confident in building intelligent products. Right now, I’m making a smart tea/coffee coaster as part of ATL Tinkerpreneur program by the Government of India during June-July 2022.
I strongly recommend that all of you should get familiarized with the working of intelligent systems using microcontrollers. An introduction to Arduino boards in TinkerCAD simulator will definitely help us to design and build new interesting and useful products.