Learning Coding Basics by Building PB&Js

5/20/24 Pratt School of Engineering

Adam Davidson recently led an outreach program that taught fourth grade students the fundamentals of coding through defining each step needed to build a classic peanut butter and jelly sandwich

fourth grade students crowd around a small robot on the floor
Learning Coding Basics by Building PB&Js

Teaching a robot to make a PB&J might not seem like typical elementary school curriculum, but that’s exactly what local fourth graders learned in a recent outreach event through Duke Engineering.

The event was held at Duke last spring for fourth-grade students attending the Duke School in Durham. The students were introduced to coding and algorithms by writing explicit step-by-step instructions for a robot on how to make a PB&J that could be consumed or packaged. The students wrote pseudocode, which is a detailed description of what they wanted the robot to do. The activity challenged the students to think critically about each step of the PB&J creation process as well as the solutions to the obstacles they encountered along the way.

Adam Davidson teaches fourth grade students to code by writing “pseudocode,” which outlines the exact steps required to build a PB&J sandwich.

Adam Davidson, senior laboratory administrator for the ECE undergraduate laboratory educational program at Duke Engineering, played the part of the robot and teacher for fourth graders taking part in the event. According to Davidson, there is little difference in teaching fourth graders and college students engineering material—it all comes down to solving one problem at a time.

“You may be able to identify 20 different problems, and maybe you don’t know exactly why they’re happening, but every problem inherently has a solution, and every solution inherently has a problem,” Davidson said. “When I worked with the fourth graders, I didn’t let them go back to solving any of the problems until we got all of them down.”

For these students, problem-solving meant creating their pseudocode by writing out explicitly what they wanted the robot to do. Some instructions were successful, and others, such as the robot squeezing the jelly container onto the bread for 10 full seconds, ended up putting the whole task in a real jam (that is, too much jelly).

With each problem came an opportunity for students to enhance their teamwork and brainstorming skills. They had to identify what went wrong and a feasible solution to fix it. That is a philosophy Davidson also uses with Duke undergraduate students in ECE 110: Fundamentals of Electrical and Computer Engineering.

Adam Davidson

You may be able to identify 20 different problems, and maybe you don’t know exactly why they’re happening, but every problem inherently has a solution, and every solution inherently has a problem.

Adam Davidson Senior Laboratory Administrator for Duke ECE

“When I work with the students in ECE 110, we work with robots and we work with a lot of code,” Davidson said. “Their tasks have these inherent problems, and some of it is that they don’t understand what the code does, so I work with them just like I do the fourth graders on the basic question of, ‘What do you want the robot to do?’”

Coming from a STEM education background in Durham Public Schools and Guilford County Schools, Davidson has honed his educational philosophy, which is that calm and collected relationships are key to tackling one problem at a time.

fourth grade students crowd around a small robot on the floor
Students from the Duke School toured ECE labs and the Shared Materials Instrumentation Facility. ECE Lab Manager Adam Davidson took the students through a coding exercise where they “programmed” him to build a PBJ sandwich, then experimented with a range of small and large robots in the school.

In his time in Durham Public Schools, Davidson noticed uncertainties about Duke’s commitment to local schools and worried about his impending career change to higher education. However, approaching his third year at Duke, Davidson has found that he has never been happier and can now see Duke’s commitment to enriching the local educational community.

“It was hard because you see this great university that wants to help and do things, but there’s always an underlying worry that if they come and help, they’re only going to do it for however long a grant lasts. So, I was a little worried when I left a job I loved,” Davidson said. “But I have never been happier than I am now with the work that I do, because it’s the same kind of work where I’m helping to build something and create a lasting program.”

Related News

fourth grade students crowd around a small robot on the floor
5/20 Pratt School of Engineering

Learning Coding Basics by Building PB&Js

Adam Davidson recently led an outreach program that taught fourth grade students the fundamentals of coding through defining each step needed to build a classic peanut butter and jelly sandwich