Archive | October 2015

Using NAO in the classroom

This year, our school bought a couple of new ‘toys’ for the classroom, to be used as little ambassadors for CS and physical computing: twin NAO robots. During 1st quarter, I used them to do mini-lessons with the 6th graders to teach them about various programming concepts, and teamwork, and to have a little fun. They are very engaging devices. I think some of the kids fell in love,  and I got many inquiries about whether they could take more computer classes to continue working with NAO.

nao1

They’re not easy robots to learn. They work with a language called Choregraphe, which is a block-based language with wires like LabView. If you dive into the blocks, there is Python code. My huge CS teacher confession is that I have never actually learned Python. It looks straightforward, but it’s overwhelming to add the new text language on top of the block language and other technical issues that came with programming the NAO – booting it up, connecting it to a network, understanding the center of gravity and the fall sensors, and so on.

 

 

nao_code

Choregraphe software.

But as with everything else, I knew I would never actually learn the robot unless I had a compelling reason to, so I told my Robotics Engineering class we were going to put away the Legos for a few weeks and do a unit on NAO programming. I don’t know if I came off as knowing what I was talking about. I told them we would make the robots dance and use the sensors and do a project. They needed no convincing.

For the first project, I used the little NAO curriculum that Aldebaran sent us, and put together a tutorial on how to make the robot dance. I divided the kids into groups and asked each group to create a short dance sequence of 10 seconds or less. We would string all of the sequences together into a long class dance.

It ended up being a really interesting activity. It exceeded my expectations.

The students created their dance moves in the virtual robot in Choregraphe, and then had to test it on the live robot. If the robot lost its balance and fell over, I made the students fix the program and bring it back when it would run without the robot falling.  It took quite a lot of time for the kids to take turns on the real robot, so if your program didn’t work, you made fixes and it could be a half hour before you could try it on the robot again.

Lots of care had to be taken with the virtual robot... easy does it with speed and range of motion.

Lots of care had to be taken with the virtual robot… easy does it with speed and range of motion.

However this created a really interesting problem-solving dynamic. Kids are used to getting instant feedback on what they try – through online math exercises, games, quizzes – the “gamification” of education is a powerful motivator. But when the feedback wasn’t instant, they were motivated by quality and care – not speed or trial-and-error. I remembered when my dad said he had to create punchcards for his programs and then fly them to Kansas City to be compiled on the punchcard reader. Talk about a long feedback cycle – his punchcards had better be perfect or else the trip was wasted! Similarly, after the kids saw their programs failed once, I rarely saw them fail twice. They brought the programs back after more thorough testing and analysis showed they would not make the robot fall over.  I saw some very careful work going into every frame of movement so the robot would stay standing.

So while I love the ideas behind gamifying your classroom, I believe there’s something to be said for activities that reward precision and diligence rather than instant gratification.

 

Making sure the dance moves are stable.

Making sure the dance moves are stable.

 

I don’t know if I could articulate what skills or concepts I was teaching the kids, but the lesson created some excitement and suspense. It was also really difficult for classroom management. Once a group was done with their dance moves, some kids caused a little trouble with each other – horseplay and such. I was consumed with unzipping files and bringing them into the Choregraphe software, and giving feedback to the kids, so I let things be more rowdy than I was comfortable with.

I’m totally building this plane as I’m flying it. I am learning a lot more this way than if I were exploring with no urgency or purpose, but it’s stressful. The next lesson I will do with the kids is to have them make a speech-recognition program that has the NAO ask trivia questions. I will blog about it then!

 

Advertisements

The Mini-World of Color: A Beginner Arduino Project

One of my favorite projects in my Electronics class is the Mini-World of Color. In this project, students create a synchronized light and sound show, complete with instructional video and tutorial.

We start with a couple of lessons on how to do the basic blinky LED on the Arduino, and then the RGB LED.  The kit we use is the Sparkfun Inventor’s Kit. Each student checks out a kit at the beginning of the semester, and they breadboard all of their projects.

The RGB LED lesson, above, introduces kids to the idea of a function. I decided at this time to make it optional to use functions. When I was a new programmer, I know it taught me a lot to do programs the long, inefficient way a few times so I really understood the beauty of functions later. But in the lesson, I show how you can compress multiple lines of code into a single function this way.

Before: 3 lines of code to make each color in the RGB LED

void setup()
{
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}

void loop()
{
analogWrite(9, 255);
analogWrite(10,0);
analogWrite(11,0);
delay(500);

analogWrite(9,255);
analogWrite(10,0);
analogWrite(11,255);
delay(100);
analogWrite(9,0);
analogWrite(10,0);
analogWrite(11,255);
delay(100);
}

This section of code combines the red and green lights into a single function. I challenge the students to add what’s needed to turn it into a single function that lights up the RGB LED with all three colors: red, green, blue.

void setup()
{
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
}
void lightColor(int red, int green)
{
  analogWrite(9, red);
  analogWrite(10, green);
}
void loop()
{
   lightColor(255,0);
   delay(500);
   lightColor(0,255);
   delay(500);
}

The next task is to learn to use the Piezo buzzer, which we do with some example code the students can hack. For a “3” grade, they have to modify the code to generate more than 1 note and make both LED’s light up. For a “4” grade, I ask them to write a function called playNote() which plays a note, compressing multiple lines of code into one.

Instructions for Piezo Circuit

Some students learn functions very flexibly at this point, and others won’t use them consistently… they will still copy and paste six lines of code for each note. This is fine. It gets the job done, and they’ll learn by creating inefficient code now.  For students that are ready to make more efficient code, I think this was helpful to them!

These activities bring us to where we are today. I talked with the students about being a Disney Imagineer. The Imagineers are some of the best, brightest engineers in the world, and it’s a very prestigious job. They are tasked with making Disney into a fully immersive experience, through rides, attractions, exhibits, movies, and so on.

I show the students a YouTube video that shows the Disney World of Color attraction at California Adventure. Most have never seen it. It’s a feast for the senses!

Their unit project is to use what they have learned about Arduino outputs to make a synchronized Mini World of Color. It uses the piezo and LED’s, but at its bare bones, it’s what the Imagineers do to create the World of Color show using a microcontroller, color mixing, sound, and coding.  Students find a song and transcribe it into frequencies for the piezo. Some look up sheet music online and transcribe the notes, while others play the song on a virtual piano and write the notes they play, and in some cases  you can find the notes and beats written out – making transcription into a song easy. Some resourceful students even download an existing music project they find and re-create it and then modify.

Students are required to make a video of their project, as well as a how-to technical video explaining the code. This is a sample from last year, playing “America the Beautiful”. These kids did an awesome job and used excellent teamwork. It was a big effort to transcribe all of those notes into Arduino code!

Student Project: America the Beautiful

I don’t have any requirements for how they write the code. It can be elegant or messy, long or short, efficient or dreadfully inefficient, well-commented or not. They might use variables and functions, or not. We will reflect on coding best practices later, but I believe they’ll learn more if they are allowed to take whatever path makes sense for them to accomplish the goal.

I can’t wait to see the creations from this semester’s group of kids. They are already planning and writing their musical light shows. One student is going to do the Star Spangled Banner while another is working on the main theme from Zelda. I joked about giving extra credit for the 1812 Overture. Maybe someone will take me up on it this year.

It’ll be a lot of fun!

“My girl programming students have been great. Better than the boys!” Why you should never say this.

“My girl programming students have been great. Better than the boys!”

“I don’t understand why there are so few girls taking computer science classes. I had this one girl in my class once. She was a rockstar!”

“I’ve worked with a lot of women, and they often outperform the men!”

Most of us don’t get the opportunity to work with equal numbers of girls and boys in the CS or engineering classroom. Isn’t it a mystery why we don’t get more? They’re so talented! I don’t think you mean harm when you make these statements about girls in computing, but I want you to think about why you have this perception and why it may be doing more damage than good.

I have the privilege of teaching two flavors of CS class. I teach a sixth-grade class, which is required for every student. It lasts a quarter and so the kids learn some basics in Scratch, a couple of other computer topics, and I send them on to their next quarter enrichment class.

I teach a seventh- and eighth-grade CS class which is an elective, and we go more in-depth on a variety of CS topics, including programming. In the spring of 6th grade, students fill out a course selection form and if they choose CS, I see them as an older middle schooler. Predictably, but sadly, it is very common to have a small number of girls, and often a few of them will drop the class at the beginning of the semester.

My sixth-grade classes are very heterogeneous. Lots of diversity in personality, background knowledge, problem-solving disposition, social maturity, size and shape and race and ethnicity and of course half my students are girls. Some of the girls learn quickly and progress quite far in the class. Some struggle a lot with the very basics and don’t get as far. Ditto with the boys. For every one of my kids, I go in with the assumption that they want to learn and do well, and some need more support than others. Some will go on to make amazing creations in Scratch and other computer tools. Some will be thrilled if they can make a little story in which characters have a dialog with each other. Both boys and girls have this very wide range of abilities.

Yet in seventh- and eighth-grade, I very rarely see a girl who is a struggling learner sign up for my CS classes. And yet boys who are struggling learners sign up all the time. High achieving students of both genders enjoy computer classes, but on the other end of the spectrum? Very common to see boys who are “non-traditional” learners who have mediocre grades, but extremely rare to see a girl who fits that profile.

What if the students aren't rockstars? Is that OK?

What if the students aren’t rockstars? Is that OK?

And often it’s with the struggling learners that you really make a connection. The kids may not pick up as fast or go as far with the computational thinking and the programming, but they work hard and improve steadily. So exciting to see a student who early in the semester struggles with syntax, with variables, with the very idea of what a computer program does, and by the end of the semester they can put together a pretty simple program effortlessly. So the programs, and the planning and the modeling and the thinking, are simple for now. So what? Look at where they came from. They’ve learned, and they can enter high school with some confidence and background knowledge. With continued work, they’ll have a solid skill set that will be a huge benefit to them later.

So consider the possibility that when the only girls in your class are rockstars, there’s a whole demographic of girls that misses out on the experience of learning this new skill – they’re afraid to, because they won’t be great at it, and the instant they feel bad at it, they’ll drop your class.  When you compliment your female students as being so much better than the boys, be careful. The struggling boys in your class are taking a big risk by trying something they know they might find difficult. You have a whole lot of girls out there in your school that aren’t taking the risk, and if they join your class and struggle, they need to know this is OK as long as they work hard and learn.

When I went to college and studied computer engineering, I went in with limited computer experience. I pulled decent grades but I don’t think I would have been classified as a rockstar. My code was inelegant and didn’t make sense sometimes. I used the wrong data structures, and I worked around things I didn’t understand, and my code was hard to read and took a long time to run and had bad user interfaces. I was new at it. I kept working, and kept learning, and I came to be decent at programming. I was able to get a job as an engineer, and I made good money and liked what I did. I didn’t have to be a rockstar at first to develop a skill set that would help me get good career opportunities. Your girls shouldn’t feel like they need to be outstanding or better than the boys. They just need to be better than they were last week.

This is a really well-known and well-documented phenomenon with girls. Jane Margolis and colleagues at Carnegie-Mellon University probably has documented it best.  Take care of the confidence of your female students. Purposefully recruit girls who don’t stand out academically. Encourage a growth mindset and consider growth in your grading policies. Give open-ended projects that have multiple ways to show proficiency – ways to extend a task for your high achievers and ways to be successful at a basic level if that’s where students are.  Offer choices. Give partner work often. Elevate the status of your hard working kids who are learning at a steady rate.

I haven’t figured out the puzzle yet as my enrollment for girls is still very low, but I’m putting in place a lot of practices this year to change it. Among those practices: I am going to convince the non-rockstar girls to give it a try, and it’s going to be perfectly OK to not be a rockstar as long as you learn.

 

 

 

 

 

 

 

Looping and Boolean Expressions in Scratch

I get a total of 18 class periods with every 6th grader in the building. I choose to spend quite a bit of that time teaching them about the basics of computer programming, using Scratch.

Last week, we explored boolean expressions. I start by having students analyze this program:

https://scratch.mit.edu/projects/56629218/#editor

Exploring boolean expressions in Scratch.

Exploring boolean expressions in Scratch.

I displayed the program just as it is, and asked the students what the cat would say. Some thought he would say “100 < 10”. Some though he would just say “100”. Many were not sure. We ran the program and the cat said “false”. Students said “Oh, I get it! 100 is bigger than 10, it’s not less than 10, so the cat said false!”
I snapped the next block into the “say” and repeated the process. This time the cat said “200”.

I snapped “touching Baseball?” into the “say” block. The students predicted the cat would say “true”, and it did.

We tried the others, and the students made predictions. By now they realized a hexagon-shaped block would  yield true or false. Many students understood the difference between “and” and “or”, and how the logic statements could be nested.

Next, we browsed through the looping statements using this program.

https://scratch.mit.edu/projects/45286218/#editor

Analyzing looping programs.

Analyzing looping programs.

For each program snippet, students predicted what the program would do and then snapped it into the program to test it. We extended the conversation by asking what we’d have to do in order to get the cat to start counting at 1, or to only say the numbers from 1 to 11, etc. We asked how to change the first script to get the cat to tumble in a complete circle. For the last script, we wondered why the cat ran and then stopped at the end of the screen.

We looked at looping and “if” blocks, and then I gave the students a challenge to be done with a partner, using the pair programming protocol. They could choose one of the two challenges here:

https://docs.google.com/document/d/1tmq77A0dBbZhGpKfEGxTpjcr1W1_A3rYDqgDpQ3quEA/edit

Pick one of the challenges below and write a program to solve it!

  1. Write a program in which a cat, in the lower left corner, has to draw a set of stairs to reach a butterfly friend, in the upper right corner.
    boolean3

The cat should ask for the height and width of each stair. Store these as variables.

Draw the stairs using a loop. If you get to the butterfly, you win! If you reach the edge instead, you lose!

For an advanced challenge, write your program so that the cat and the butterfly start in random locations at the start of the game.
2) Create a guessing game similar to the game we played with the robot. Have a creature ask you how old it is. If your guess is too high, say so. If your guess is too low, say so. If you’re correct, then you win! Keep trying!
For advanced challenges, give yourself only 10 guesses to get the right answer. Also, have the creature set its age to a random number at the beginning of the program.

 

Students were really excited to tackle the challenges and made some creative and fun programs. I wanted to take it in a direction where we analyze the best strategy for winning each game. What should you guess if you want to win the age-guessing game in as few guesses as possible? Can you look at the position of the cat and butterfly and estimate width and height values of the stairs that would win? I still hope to bring these up next week.

These were some of the programs kids submitted.

Stairs program:
EAT THE BANANA has some great features and really causes you to have to develop a strategy to get stairs to reach the bananas.

This one places the cat randomly at first and does a good job determining whether you win or lose!

This squirrel and acorn program had a different twist. You also had to guess how many stairs you were going to make. After drawing the stairs, if you’re touching the squirrel, you win! In addition, their algorithm involved turn-move-turn-move instead of change x – change y – repeat.

 

 

Age Guessing program:
GUESS THE DRAGON’S AGE is pretty full featured. It quits if you don’t guess the age in 10 tries! I hypothesized that I could always guess in 10 tries as long as the age was 1-100.

An adorable “Guess how many times I’ve decorated my house” game that doesn’t bound your guesses – devilishly hard.

This cute one had you guess the age of two characters instead of just one.  https://scratch.mit.edu/projects/78051070/#editor

 

I enjoy how Scratch projects often involve artwork, storytelling, and creativity. This student weaves in splash screens and a story about hunting and killing a unicorn into the stairs program.
https://scratch.mit.edu/projects/77821546/#editor

 

The challenges were engaging and great for partner work. I wonder if they liked this better than a more open-ended game assignment. I will ask them as the quarter finishes up!