Activity

Code Your Garden

Overview
Grades 5-8
60 min
Topics
AgriscienceComputer Science
Status

Welcome to the garden of code! You may not think something outdoorsy, like gardening, can have anything to do with something indoorsy, like coding, but you’d be surprised!

In this activity, you’ll identify some computational thinking skills, including pattern recognition, decomposition, abstraction, and algorithmic thinking. You’ll also be able to define the terms variable and looping as they relate to computer science. Then, finally, you’ll apply the concepts of computational thinking skills, variables, and looping to create a garden layout.


Garden seeds that grow well in your area

Glue stick

Roll of biodegradable paper towels

Pen or pencil

Ruler


1

Before you can plant a garden, you have to design it! Gardeners must use space efficiently, but they also have to provide enough room for the plants to grow. Computational thinking can help make the most of a space! In this activity, you’ll use four different computational thinking concepts to design a paper towel garden. You’ll also use variables and loops, but don’t worry, we’ll get to that soon!

Did you know?

Computational thinking is a way of thinking that can be used to solve many types of problems, not just computer and coding problems.

These are the four types of computational thinking you’ll use in this activity. You’ll also see some ways you’ve been using computational thinking in everyday life without even knowing it!

  • Pattern Recognition: Recognizing patterns is one of the first things people learn to do. It’s built into our DNA! Babies learn that if they cry, someone comes to help them. Pattern recognition is just the act of looking for patterns in different processes. You’ve used pattern recognition when you notice that an adult won’t drive a car if you haven’t buckled your seatbelt. If you use public transport, you’ve also probably noticed that you can’t get on the bus or the subway until you’ve scanned your card. When creating a computer program, a software engineer looks for patterns of things they should do to create code.
  • Decomposition: Decomposition is the process of breaking a problem down into small steps. When you are making your breakfast, you probably think about each step of making it rather than thinking about the whole thing at once. It might look something like this: Get bowl, pour the cereal into the bowl, pour milk over the cereal, then eat. Software engineers use this same process to break down a problem into manageable pieces.
  • Abstraction: Abstraction is the process of pulling out the important parts of a problem so you can focus on them.  If you are playing a video game, you probably turn the gaming system on, sit down with your controller, and play the game. You don’t have to think about what is going on inside the gaming system to make the game work. This is a good example of abstraction. In coding, abstraction makes sure the person using the code is only seeing the important data. This helps makes the code less complex and allows the program to run faster.
  • Algorithmic Thinking: The word algorithm means “a set of instructions that can be used over and over again.” Algorithmic thinking is a way of looking at a problem to find those sets of instructions.  Tying your shoes is a great example of algorithmic thinking! The process of tying your shoes is probably something you had to remind yourself how to do when you first learned it. But now, you know the set of instructions to tie your shoes, so you can do it over and over again without really thinking about it. A computer programmer can use algorithmic thinking to find a task that needs to be repeated and create an algorithm to make a task more efficient.
2
Designing Your Garden

One of the most important things to identify to make your garden successful is whether or not the seeds you choose will grow! The US Department of Agriculture has created a Hardiness Zone Map to help gardeners know which crops will grow well in different places. The full map can be overwhelming to look at, but if you do an internet search for “USDA Plant Hardiness Zone Map,” you can type in your zip code to zoom in on the map!

Did you know?

The backs of seed packets are designed to help gardeners be successful! There’s a lot of information on the backs of these packets, but by using abstraction, we can pull out the most important information.

Step 1

Once you’ve chosen your seeds and read your seed packets carefully, it is important to make sure you get the spacing for your seeds right! The variable of which seed you are planting will determine the spacing you need. You can use a chart like the one below to help you keep track of the spacing for the seeds you chose.

Step 2

Tear off a 12-inch by 12-inch piece of paper towel from the roll. Using the data you collected from the seed packets, decide how far apart you need to plant your seeds. Using your ruler, mark how far apart the seeds should be on the paper towel. Recognizing a pattern as you set your paper towels up can help you speed this process up. Here is an example of what your paper towel might look like when you’ve completed this step.

Step 3

Next, you’ll fold your paper towel until it is the right size to keep your seeds spaced the proper distance apart. Folding your paper towel over and over is a repeating loop. Depending on the spacing for your seeds, this may look a little different.

Step 4

When your paper towels are folded to the right size, use a glue stick to glue the right amount of seeds onto each section of the paper towel. Remember, you can find the correct number of seeds to glue by reading the seed packet!

Step 5

As long as it’s the right growing season for your seeds, it is time to plant! If you do this activity outside the growing season, you can save your paper towels for planting.  Plant your seeded paper towels, and make sure your garden gets the amount of water and sunlight listed on the seed packet. You should have a beautiful garden in no time!

Bonus Activity

Test the accuracy of your algorithm (planting plan) with a friend.  First, calculate how many folds it will take to make squares the right size and then write instructions for your friend to follow.  Ask yourself the following questions when you’re done.

  • Was the experiment successful? Was your friend able to make the squares the right size by following your instructions? If so, you have created a successful algorithm!  If not, you can debug your planting code by adjusting your instructions to provide an improved algorithm.
  • Test another variable by repeating the process with a different kind of seed that needs more or less growing space. Repeat until you have the garden you want!

1

How did you use decomposition to break down your gardening project?  How did you decide what to plant? Did breaking down the problem into smaller pieces make it easier to lay out your garden?

2

Did your garden follow a predictable pattern?

3

How did you use abstraction to simplify the project?  For example, did you set aside packets of seeds you chose not to use?

4

Did some variables (types of seeds) work better than others?

5

Was it easier to code your garden with smaller or larger crops?

6

Was it easier to code your garden with smaller or larger crops?

7

Did you have to adjust anything to create your algorithm? For example, did your paper towel squares measure 12 inches by 12 inches, or did you have to adjust?

8

How could you improve the process of coding your garden?

Did you enjoy thinking through the process of how to fold the paper towel correctly to create the right spacing? You might enjoy origami! Origami is the ancient Japanese art of paper folding to create different figures. You can learn more by checking out a book from your local library or searching the internet for tutorials!

Gardening can take up a lot of outdoor space, and space isn’t something everyone has access to! To help solve this problem, many people have created community gardens. Community gardens can be used to grow food for the community, grow flowers for pollinators, or even to provide a place for people to gather together and take care of the Earth. You can search the internet for “community garden in My Town, My State” to find a garden near you!


Even though the idea of combining technology and agriculture might be something you didn’t think of before, there are actually jobs that combine these fields!

  • Software Developers in Crop and Soil Science: There are computer scientists who create programs to analyze crops and soil so that we can produce higher quality and more bountiful food crops.
  • Data Scientists collect and analyze data to manage crop growth, disease, and water needs.
  • Unmanned Aircraft Systems (UAS) Pilots operate drones to help agriculture by surveying crops to look for disease and dry spots, applying fertilizer and pesticides, and to survey grazing animals.

Did you enjoy this activity?

No endorsement by 4-H is implied or intended. 4-H is the youth development program for our nation’s cooperative extension system.