Showing posts with label coding for kids. Show all posts
Showing posts with label coding for kids. Show all posts

Saturday, November 14, 2015

S4A (Scratch for Arduino) Project - A Math Game using LEDs: Version 2, with a Single Sprite

Here is a much simpler version of the previous Math Game using LEDs: The aim is to design an interactive Math video game, where you ask questions and if your answer is right, an LED lights up. In the previous version, you had two sprites that communicate with each other, checking the values of variables. In this much simpler version, there is just a single sprite - the Arduino sprite itself, that asks questions and checks the answers for correctness. This version takes away any complication involved in maintaining a communication channel between the sprites, and is probably the easiest way to start off. The following is a formal lesson plan for the same; a set of slides are also provided. The assignment is intended for students in Grade 5 and higher.

Aim

A gentle introduction to the Arduino hardware, with S4A (Scratch for Arduino) as the IDE.

Objective

Introduce the students to the Arduino platform, via a simple project to light up an LED. The students use their knowledge of reactive programming & conditionals

Saturday, August 22, 2015

Blink 2 - An S4A (Scratch for Arduino) Project using a Breadboard & an LED

This is version 2 of Blink, where we shall see how to use a solderless breadboard to connect an LED to the Arduino. Learning to use breadboards is very fundamental to building circuits. The S4A (Scratch for Arduino) code we shall use here is exactly the same as in the previous Blink project. And the exact same blink functionality for the LED will be developed, but using a different wiring this time involving a breadboard.

Why use a breadboard? A breadboard is a quick, easy way to prototype a circuit. It allows you to experiment with electronic circuits, build and test them without any soldering. It can be used to build the simplest of circuits to very complex ones. You can read more about breadboards here and here.

Back to Blink2... We shall connect the LED to Pin 13, just as we did in Blink version 1. The S4A code for blinking the LED turns it on and off, with an interval of 1 second, to provide the blinking effect.















Here's the wiring we shall use for Blink2 with the above S4A code:





























As you can see from the image, the LED is placed on the breadboard this time, rather than connected directly to the board as in Blink version 1. We use a resistor to connect the positive leg to Pin 13. The negative leg is connected to the GND (Ground) via a jumper wire. (Both jumper wires and resistors come as part of the Arduino kit. You can also buy them in bulk at stores such as Fry's, RadioShack, Amazon, etc.)

Here, we take advantage of the fact that all the components in a row on either side of the ravine on a breadboard are electrically connected. We connect one leg of the resistor to the same row as the positive leg of the LED, and connect the other leg of the resistor to Pin 13. The resistor is used to limit the electric current flowing in to the LED, and to ensure that the LED does not burn out due to direct power from the Arduino. The jumper wire from the Arduino GND (Ground) is connected to the same row as the negative leg of the LED, to complete the circuit. The electric current will flow in to the LED from Pin 13 through the resistor and flow out to the GND (Ground), thus completing the circuit.

Now, click on the green flag on the S4A screen and watch the LED blink...























Tuesday, June 16, 2015

Pac-Man is Chasing my Planet!

My child's class was recently introduced to Cartesian coordinates in Math. And in our coding class, we have been practicing interactive programming for the last few weeks. So, I thought of putting together a very simple template that  combines both the concepts, that the kids could then remix...  Pac-Man is Chasing my Planet! was the result... took me less than 10 minutes to put together and the kids loved it.

We went through the Pac-Man template code as a group & discussed the use of the XY coordinates. I showed the kids how the XY coordinates displayed under the Scratch animations area change, as I move the cursor around on the screen. Our discussion then proceeded along the following lines:


  • If I wanted my sprite (the planet, in this case) to move anywhere the cursor moves, what values should I use for the sprite's X and Y coordinates? 
  • The above point was also a good place to talk about variables, and how the change of the cursor position is always reflected in the planet's position. 
  • Should I move the planet around for just a few times or all the time? What kind of a loop should I use here?
  • How can I make Pac-Man always follow the planet? Which loop should I use? 
  • What values should I use for Pac-Man's X and Y coordinates? 
  • Here, the kids quickly saw that without a small degree of separation between the coordinate values of the planet & Pac-Man, the two sprites overlap each other.
  • BTW, the "if-else" clause was purely optional, for those to wanted to add another level to their game. The majority went with just a "go to x() y()"
  • And finally, the interactive part of the game... I put in the requirement that there should "a key press" or "the green flag click" to make the game start, and something similar to end the game. 

In the next one hour, the children came up with multiple variations of the game, making their own sprites and designing various versions of tag... All in all, a very fun class for them and me to wrap up the school year.

Happy Summer!!

Tuesday, April 21, 2015

A Drive through the Zoo: Learning about Angles using Pro-Bot

My child's class started learning about angles about a week ago. And the teacher requested me to design an exercise for Pro-Bot that will introduce the idea of angles. As the kids are very new to the concept, I wanted to keep this one fairly simple, while still using a mix of acute, obtuse and right angles.

A trip to the zoo is almost always part of our field trips every school year. The zoo in our city happens to have buses that drive along the various points of interest/ themed animal enclosures. I felt that the turns made by the bus in this familiar setting of the zoo, might be a good way to introduce angles.

In this exercise, a scaled down version of the bus route, provides the path for Pro-Bot to drive on. As the Bot drives along the path, it is required to make angular turns at each point. I have provided the angular measurements required in degrees and distances in centimeters. The bus travels in a loop, the directions are shown using arrows. Note that the map below is not drawn to scale.





Based on the above map, write a program for Pro-Bot to drive along the following paths, assuming that the Pro-Bot is facing in the forward direction:
  1. The path from the Entrance of the zoo to the African Savanah. How many turns did the Pro-Bot make? Were the angles acute, obtuse or right angles?
  2. To continue from the African Savanah (where you stopped before), to the Elephants enclosure, how many degrees did the Pro-Bot turn? 
  3. Program the path from the African Savanah to the Raptors. How many turns did the Pro-Bot make? Were the angles acute, obtuse or right angles?
  4. Continue the path from the Raptors to the Kids' Play Area. Did you use acute, obtuse or right angles for the turns?
Alternatively, the kids can be asked to program the entire bus route as a single program, marking the types of angles used along the way.


Saturday, February 7, 2015

code.org in Elementary School: A Review

code.org is a great place to start for someone new to coding. It is a non-profit that is dedicated to introducing children to Computer Science. They have a self-guided curriculum for elementary school students in K-5, consisting of several courses, designed for different age groups. The lessons are extremely fun & based on themes that are familiar to children. The animations using popular characters especially appeal to young kids. My child has been working with it since the end of summer and has thoroughly enjoyed it. I also use it in my kid's classroom and the response from the students has been amazing. We recently did the Hour of Code during the Computer Science Education Week (Dec 8-14, 2014) with the Angry Birds and the Frozen themes.

The following is my review of code.org for elementary school, based on my experience with it in the classroom and at home. We are currently focusing on the Hour of Code lessons in my classroom, along with Course 1 in Code Studio, but the points mentioned below apply to the other courses in Code Studio as well.


Love the following features:

1.  The curriculum is visually appealing to children, with the use of popular characters from movies and video games. Once captivated by these themes, the kids tend to treat it almost like a video game. I am yet to meet a kid who does not like to play around with Angry Birds :)

2.  Concepts are introduced one at a time, building up the student's knowledge in an incremental manner. Each concept is backed by multiple exercises, providing adequate practice opportunities.

3.  I really like it that the kids can move along at their own pace.

4.  Great page layout: Well organized, easy to understand and intuitive to use. Consists of instructions in a toolbox, an animations area to run & test the program, and a counter to track the number of instructions used.

5.  Only the subset of instructions that are required to design a given program are provided at any time. I find this to be extremely helpful in keeping little brains focused on the task at hand.

6.  The max number of instructions that are actually required to run the program is displayed at the top, along with a counter that keeps track of the number of instructions written by the student. This is extremely helpful to the children to keep an eye on the size of their programs. In my current classroom, I find it to be especially handy for those who forget to use Repeat Loops.

7.  The pre-designed curriculum makes it easy for everyone to use. The embedded tutorial videos are pretty cool as well.

8.  The Class Management Tool is great! Each course can be set up with a list of students in it. Adding and deleting names within the list is easy. No emails are required from the students, a huge plus for setting up accounts for the under-13 age group! The passwords can be set to words or pictures; I use pictures for passwords in my classroom & find it to be convenient for the kids to remember.

9.  The Class Management Tool tracks each student's progress in a course and marks the lessons as (a) done perfectly, (b) done correctly but with more instructions than required, (c) not completed. This is a big help to the instructor to figure out who needs help with what.

10.  I also like that the organization conducts free workshops for instructors, which greatly helps demystify the software for teachers who are not familiar with Computer Science.


A really interesting observation in my classroom while using code.org was that there was a lot of teamwork and willingness to coordinate with each other, even though each child was working on his/her own laptop. The children talked and discussed issues with their peers, helped each other out... all this without any prompting from me or the class teacher :)


Having talked so far about several features that I like about the tool, here is something that I would like to see implemented differently:  Once the program is written, the code is not saved. You can run the program, but once you move on to a different lesson, the previous code is gone. This hinders the ability to revisit and edit a piece of code. If a program was written with more instructions than required or if it was not completed, the tracking tool reflects it, but there is no way to go back and help the student fix the program. This feature was originally present but seems to have been taken out sometime towards the end of summer. Would be really helpful to have it restored.

Very happy to see that this feature (highlighted above) has been restored as of April 2015. The original program now gets saved, allowing you to revisit and edit it. There is a new "Start Over" button at the top of the screen that allows you to erase your program and restart.

The new "Answer Viewer" section that pops up when you are reviewing a student's work is quite helpful. It comes with two buttons "See the Solution" & "Try it Yourself". Quite a handy tool for teachers... 

Overall, I look at code.org's introductory curriculum as a stepping stone towards more advanced platforms such as Scratch (www.scratch.mit.edu). As mentioned above, allowing the child to focus on just the required tools initially, than being given a huge set of choices helps to focus and identify the use cases for the various concepts later on. Plenty of practice with each concept and the ability to move along at the child's own pace enables the readiness for more advanced, creative projects.


Tuesday, July 29, 2014

Pro-Bot drives up a steep mountain


Pro-Bot is trying to go up a mountain. But the mountain is so steep that for every 4 miles that Pro-Bot climbs up, it slides back 1 mile. Pro-Bot attempts this 5 times. How far is Pro-Bot from its starting point at the end of the 5th attempt? 

Write a program to trace the path taken by Pro-Bot. Use 1 cm to represent 1 mile in your program.
Do you see a repeating action here? If yes, can you use a Repeat Loop in writing this program?  

After tracing the path with Pro-Bot, use a ruler to measure the distance traveled to check if it matches the distance that you calculated.






I designed this question to let the children map a word problem to a math problem and finally to a computer program. It represents a real-life problem solving scenario which includes reading and understanding a word problem, identifying recurring patterns in it, applying mathematical concepts to the problem, scaling of quantities to reasonable sizes and finally coming up with the solution to the problem in the form of a computer program.



The solution is a very simple program:

  Rpt 5 [
  Fd 4
  Bk 1
  ]

The total distance traced by Pro-Bot is 15 cm.


Help Pro-Bot find his way home


Pro-Bot has been on a trip to a new park and needs to find its way back home. The GPS says that Pro-Bot has to travel 9 miles North from the park, then 7 miles East and finally 2 miles South to get home. 

Can you write a program to trace Pro-Bot’s path as it finds its way home?
Use a scale of 1 centimeter to represent 1 mile in your program.





















I designed this question to go along with the Geography lessons in class that teach the North, South, East & West directions. It allows for the children to map the compass directions to Logo instructions in Pro-Bot. It represents a real-life problem solving scenario which includes reading and understanding a word problem, applying concepts of computer science to geography and math, scaling to reduce the size of the figure traced by Pro-Bot and finally coming up with the solution in the form of a computer program.



The solution is a simple 5 line program:

  Fd 9
  Rt
  Fd 7
  Rt
  Fd 2

Monday, July 28, 2014

Introducing Pro-Bot to kids

Pro-Bot is a floor robot from Terrapin. It can be programmed to draw figures or trace paths. Pro-Bot is controlled by a computer inside of it. 

Before we go into the details of Pro-Bot, let's quickly look at what a computer is.  A computer is a machine that can perform tasks according to the instructions given to it. It can take data, store it and do calculations with it. The instructions to a computer are typically given in the form of a "program". A computer can only do the tasks for which it has been programmed.

For most people, the word computer brings to mind the image of a laptop, or the box and the screen sitting on a desk top. But computers don’t always look like that. Computers, big or small, are present in so many more things that you are familiar with: tablets (like the iPad), cell phones, video games, music systems, cars, trains, ships, airplanes, space shuttles, TV, microwave, electronic toys… and of course robots, including your Pro-Bot.

A couple of words that you commonly hear in relation to computers is Hardware and Software.

Hardware refers to the parts of a computer that you can touch and feel. For a desktop computer or a laptop, the screen (monitor), keyboard, mouse, headphones, cables, circuit boards, etc., are all part of hardware. For your Pro-Bot, the keypad, LCD screen, digital circuits, power supplies, etc., are part of its hardware.

Software refers to the programs that tell the computer to perform its tasks. Of course it is not something that you can touch and feel like the hardware (though you can see it, read it and write it). The programs that you write for your Pro-Bot is part of its software.

Pro-Bot uses a computer language called Logo. The programs that you write for Pro-Bot will use instructions written in Logo. Pro-Bot has arrow keys, number keys and a few special keys mounted on its back that you will use for creating the programs. The instructions that you type in will be visible on Pro-Bot's LCD screen. Pro-Bot will follow the sequence of instructions in the order that they were entered, one at a time.

More product information on Pro-Bot can be found here:
http://www.bee-bot.us/probot.html