As a dad, I want to teach my kids the things I learned later in life, hoping they get a head start. One day, I decided to introduce my three kids to the world of programming, starting with HTML because I thought it would be easy. To my surprise, only one of them was interested.
I am always inspired by watching Dr. Ruchira Wijerathna’s ‘Science With Ruchira’ YouTube channel. One day, I showed my kids his ‘DIY Arduino RC Car’ video (In Sinhala Language), as they are big fans of vehicles.
After watching the video, they asked me,
“Can’t we build one?” I thought it was a great opportunity to introduce them to programming and the basics of project management.
I said, “Yes, you can build it yourselves. I can help.”
Their next question was, “How can we build such a vehicle ourselves?”
When I heard their question, I remembered what I learned from Johanes Broadwell 10 years ago, He taught us that any project (or any task in a big project) can be achieved by breaking it down into four steps.
Johannes wrote about that experimental approach in his blog under Pair programming with Sankalpa. I applied the same technique in several software projects, and I have personally found it very effective.
I said ‘Yes, you can build that in 4 steps’.
Lets call it ‘jeep’, they named it.
Our goal was to build an all-terrain vehicle with a camera for real-time viewing.
First we started experimental jeep version.
This phase’s milestone is to have something controlled by an Arduino board.
To start the project, we checked what we had on hand. We had only one NodeMCU board and a laptop. I suggested ordering differentials and other required parts for the Jeep online, even though it might take some time for them to be delivered. But the kids said, “No, we have a differential from an old toy. We can build the chassis ourselves,” the brothers insisted.
After spending 1-2 days on mechanical work, they came back with a chassis built from plastic bars, two different types of wheels, and a working front axle. The vehicle wasn’t very solid, but it was enough for an experimental version. The front axle consisted of two motors: one for moving forward and backward, and another for turning left and right.
Then we tested both axle mechanisms and found that only the front axle was working completely. The rear axle had some mechanical issues, but it was enough to build an “experimental”, “simplified” or “simplified” version of the Jeep.
And could find two 1200mah batteries from old emergency lamp.
Next, we got started with the Arduino IDE and try to understand simple code. We used the Ardunio Blink LED sample.
Taking it one step further, we planned our real code. I asked them to write some pseudocode for the program. The elder brother had already learned this in school, and what they wrote was acceptable. That was the first virtual sprint we ran.
We started the next sprint by preparing other required items. We bought an L298N motor controller and other necessary parts from a nearby electronics shop, and they completed the wiring.
Next, it was pair programming time. We needed to program our vehicle for actions: forward, reverse, turn left, and turn right. Together at one desk, I showed them how to program the vehicle to go forward. Using this function vehicale could go forward to given time.
Then, with my help, they programmed it to reverse. They managed to program it to turn left and right by themselves. After a few rounds of testing and bug fixing, they achieved that. Then we had a ‘jeep’ which run forward few seconds, then reverse back and turn left and right by it self. No action can be controll remotly.
As all the vehicle’s actions were handled by a single function, I thought it was a good time to introduce ‘Code Refactoring.’ Together, we created the first custom function to handle the forward action. After they completed the other three functions, we marked the end of the second sprint.
And also that marked the completion of the first step, the ‘Experimental Jeep Version,’ of this project.
My initial plan was to build a webpage to control the vehicle. However, when I mentioned this, their faces didn’t look enthusiastic. They had already watched some videos and had ideas about other solutions. They said,
“We saw something called B_ly_nk. Can’t we use that?” After thinking for a moment, I realized they were right. They were eager to control their vehicle remotely, and building a webpage might be too complicated, potentially causing them to lose interest in the project.
So, I said, “Yes, let’s use ‘Blink’
Blynk is easy to understand and less complicated for them. We installed the required library, downloaded the mobile app, and modified the code to support it. First, we tested it with only the forward action. The code compiled but failed to upload to the module. After trying a few more times with the same result, we discovered the issue was with the board and the same problem occurred with other similar boards. We found that we were using CH340 boards, which are less reliable than CP2102 boards. We had to wait about 5-6 days until the new CP2102 board arrived
We restarted the project the day the new board arrived, uploaded the code, and tested it. We tested the forward action first through the Blynk app, and it worked. Then, they had to complete the other actions. After an hour or so, they came back complaining that even when they tried to reverse or turn left or right, the ‘Jeep’ only went forward.
We started debugging by first checking the wiring to ensure there were no issues. Then, we began checking the code. We found that we had four different functions for each action, but all the actions were identical. At first, I wondered how this happened since we had already tested our ‘Jeep’ actions in the second sprint. Later, I realized that the issue occurred after the code refactoring, and we hadn’t run any unit tests since then.
We corrected the code, and finally, it worked. I still remember their faces after successfully owning their own built remote-controlled ‘Jeep.’
I am going to stop here with the end of the Basic Jeep version. The simplified and complete version is yet to come.
Happy pair programming!
What we pair-programmed: https://github.com/sankalpaa/Jeep_source/blob/main/arduino/source.ino.
# | Name | Role |
---|---|---|
1 | Happy 12 Year old 👦 | Pair-Programmer, Team Lead |
2 | Happy 8 Year old 👦 | Pair-Programmer, Cheerleader |
3 | Happy 6 Year old 👧 | Quality Assurance, Cheerleader |
4 | Happy Me 🧔 | Pair-Programmer |