Finite State Machine

My monthly middle school library code club met this week on April Fools Day.  I thought it would be fun to make a joke or prank project but I wanted to give some boundaries to the students, too. I was a little bit worried that we might end up with some inappropriate projects.

I kept thinking about one project that a middle school student made during the Winter Carnival coding sessions.  In addition to his animation, he had a simple button on the screen that said: “Don’t press”. Of course, users are going to press it.  Pressing it made a really annoying and alarming sound. I thought this type of project would make a great April Fools project for my group.

When I started to make my own version of the “Do Not Press” project,

I realized that I wanted different things to happen: first one thing would happen, then something else, and so on. Each time you pressed the button something new would happen. I would need a way to check how many times the button had been pressed and use that to decide what would happen. I needed a finite state machine (at least a very simple one).

Screen Shot 2019-04-03 at 9.58.31 PM

A finite state machine, FSM, is a basic computer science concept for controlling the logic of a program. The concepts center around keeping track of the state and what it takes to move between different states. This example is the simplest form of FSM. Now I had a lesson to teach the students and a fun prank project for them to make, too.

Using a single variable to keep track of the state of the project can come in handy for many types of projects. I had a couple of the coders in my mind who would find learning this concept useful in the programming they like to do.

The coders did find the project fun.  A few of them expanded on my starter project and a few them took the concept and used it in their own original way.

I only wish I had not made the final state check “if state > 3” but “if state = 4” in my example.  That would have made it easier for the coders to add on more states.

Advertisements

Snack Discussion

I’ve started my eleventh 4th-grade after school Code Club session. We’ve met three times and things are going well, but I’ve neglected to blog.  I’m using the same club format and the same projects I’ve blogged about before, so there was really not much to write about.  After this week’s session, though, I found I have something to share.

Screen Shot 2019-03-16 at 9.24.16 AM

Week 2 project: Maze game by a 4th-grade code club member

Code Club starts right after school – literally, the last bell rings and the students walk from their classroom to the computer lab. We start by circling up the chairs and having a meeting time where I take attendance, talk about what project we are going to do, and have a snack. (Snacks are provided by members who volunteer to bring something to share with everyone.)

Since we can’t eat while coding on the computers (school policy and good rule in general), I use this beginning time to talk about computer science, my coding objective for the day, etc.  This group is a very easy-to-manage and attentive group so I have made an effort to start a snack discussion to fill this time. Their thoughts and ideas are helping me craft the club to fit their needs.

IMG_0744

This first day I asked them what their favorite computer/video game was. Their favorite games ranged from themed games like Harry Potter to popular MMO games like battle royale type games.   No real surprise there.

The second week I asked them what types of games or projects they wanted to learn to make. I wrote down their list of ideas.  There weren’t many surprises, but I do have a number of girls who want to make a virtual pet style game, so I’ve added that to the learning projects I will present to them.

This week I asked them what they thought was the hardest part of coding. This was exciting because many of them felt comfortable enough to share their concerns.  I listened and affirmed that all of these were difficult parts.

I have a volunteer, who is a middle school math teacher, and she shared her concern that the hardest part for her was when a student asked for help but only said, “this isn’t working”.  It is true, that it is difficult to figure out what is not working in code at first glance. It would be helpful for the students to explain what they were hoping would happen and what was actually happening in their code.

Some of the other parts they thought difficult were:

  1. finding the code blocks they were looking for.  (I have to remember that they are very new to Scratch.)
  2. using the costume editor. (Another student gave some tips on this – like switching out of vector mode to draw. I thought it was great that they are helping each other.)
  3. coming up with the design of the project they want to make. (I affirmed this was a difficult part. A good design plan makes the rest of the project go smoothly. For some games, the design phase takes 50% of the total time from start to finish.  I also told them that when designing their game, they would fill out a Game Design Document to help them make those design decisions.)
  4. finishing the project/ getting the project to match their expectations. (Wow, these are insightful kids.  Yes, I told them that I and the volunteers would help them manage their project.  First by making sure it was a project that could be done and second, by helping make a plan for them to get it done in time.)

The snack discussion has become a favorite part of Code Club for me.  I hope I can come up with more good prompts.  Maybe I’ll ask about getting unstuck next.

I am also enjoying teaching them to code and playing some of their creative projects, too.  Here are a few screenshots.

Screen Shot 2019-03-16 at 9.23.56 AM

Week 3 project: Quiz-type Chatbot by 4th-grade Code Club Member

LMS Winter Carnival

Last week I ran two coding sessions at the middle school for their Winter Carnival.  There are a wide variety of activities offered for the 5th- to 8th-grade students during the morning, divided into two 1.5 hours sessions. Options ranged from skiing, dancing, and ping-pong, to cookie decorating, tic-tac-toe, and D&D.  I was invited to offer Scratch coding.

My activity, Coding/Scratch, had this description: “Students will have the option to create a game, animation or pursue a passion project of their choice using Scratch 3.0 coding environment.”

Despite the unlimited options in the description, I wanted to offer some project guidance as I didn’t know the coding experience of those who would sign up. I decided on three projects from Code Club World that in my experience offer students the greatest creative choice coupled with step-by-step instructions.  The first option was Chatbot.  I’ve discussed how much I like this project before and with the added text-to-speech options in Scratch 3.0, I knew this would be a hit. The second option was a “clicker game” presented with Code Club World’s Ghostbusters project.  The third project was the “side-scrolling platform game” Flappy Parrot from Code Club World.  I feel any of these three projects can be accomplished in 1.5-hours with this age group.

In preparation, I went through and created starter versions of these projects. I also set up a Scratch studio for everyone to share their projects. Once the students were logged into Scratch (some had to make their own, new accounts), I invited them to be curators so they could add their projects to our group studio. This part required a bit of administrative time but it is not difficult and works well for everyone to have a single place to go to play each other’s projects. I feel it is important to carve out time to share and showcase what everyone has accomplished, knowing that we all had a limited amount of time and that the projects aren’t perfect or even finished.

About ten students signed up for each session but only one girl in each session.  One of the math teachers joined me- she is eager to learn Scratch and we work well together.  I knew more than half of the students and some of them were with me in past Code Clubs. I think the students had a good time. I definitely feel like we supported their ideas and creativity. I’d love to get feedback from them. I shared the project studio with the school administrators and they thanked me for participating.

Screen Shot 2019-02-22 at 3.13.51 PM

Chungus Run – a creative Flappy Parrot game – good instructions, too 

Some notes from the sessions:

  • Time management is key with short sessions – I posted our schedule – Intro 10min/ Plan 10min/ Code 55min/ Share 15min
  • The project guides were helpful even if only to get them started before they went off on coding tangents.
  • These students showed creative, flexible thinking. Scratch supported their creativity by making coding flexible to their ideas.
  • It is difficult to share something you know is incomplete.  I announced a time check at 15 minutes before we wanted to share, so no one was caught unaware.
Screen Shot 2019-02-22 at 3.17.30 PM

Fishie Click game – former 4th grade Code Club member

Coding projects are like art – they are never really “finished” or “perfect”.  They are “done” when you decide to stop working on them. – I said this to someone who was bemoaning the end of the coding time and another student laughed.  She clarified that she was an artist and understood that fact very well.

Screen Shot 2019-02-22 at 3.16.38 PM

The Majestic Bird – Well done and so annoying!

 

Timing & Video Sensing

Last week at Creative Coders Club we played with video sensing in Scratch 3.0. It was a ton of fun.

I originally wanted to teach the students some new coding techniques to add to their skill set and thought about introducing using timing and timers.  Adding the wait time block to music or animation can produce powerful effects.  Also, adding a count down timer in a game can make it more thrilling.  I remember having a Getting Unstuck challenge in this theme of using time-related sensing blocks. Here are the examples I presented to the students:

Screen Shot 2019-02-14 at 7.22.42 PM

Learning project from YoungHacks which shows a bunch of uses of timing blocks

Reaction Timer

Allenqin22’s project uses Cloud variables – another thing I need to introduce to my coders.

 

I also thought this reaction timer example would interest the middle schoolers.

 

 

While I was looking for examples, I found this featured project, called Excuse Generator, which the students did enjoy looking at. It was not related to any ideas I was presenting, but it was such a cool project by a new Scratcher I had to share!

Screen Shot 2019-02-14 at 7.15.42 PM

Scratcher Rose-Pearl’s Excuse Generator

The biggest hit turned out to be the video sensing extension.  I knew it would be a great fit for this group when I found the Scratch Team’s Save the Minifigs project. This group would love creating something like that.   My co-leader Kathy agreed.  She found and printed the Scratch video sensing cards for the group.  Since we use Chromebooks, we had easy access to webcams.

We had some technical trouble with the Wifi, not related to Scratch and students had to work in pairs while we worked on getting more computers up and running. In the end, the students didn’t feel like they had enough time to work on this topic so we will revisit video sensing next month.

Here’s what they were able to accomplish.

Screen Shot 2019-02-14 at 7.44.21 PM

Catness – pet the cat and get some strange effects.

(I was going to add more pictures but who wants to see my face multiple times? Just go to the studio link above and check them out.)

One funny note: As I was circulating around to help students, I would inadvertently cross through the webcam’s view of someone’s project and cause all sorts of havoc.  I would also misinterpret someone waving as someone needing help and zip around – through the webcam’s view of others, only to find they were just testing video sensing.  We meet in a library conference room with windows to the main area. I imagined we looked strange with all the arm-waving going on.

I can’t wait to continue with this next month.

New Year, New Scratch

Creative Coders Club on Monday was one of our best sessions ever.  The kids were really creative and funny and fun to work with.  The kids that came were all returnees and familiar with Scratch.  It was their first time working with Scratch 3.0 and despite a few grumblings about where familiar tools went, they were able to create some creative projects.  For such young people, they really seem upset about the changes to their coding environment.  I’m sure they will get used to the new version and not look back.

When I was looking for a project this month I noticed the tutorial from Cartoon Network on Animating an Adventure Game.  I knew the Creative Coders had been wanting to make an adventure-type game.  I added this option to our January studio and went through the tutorial myself so I could field any issues.  It has some fun character Sprites but turns out to be a simple “collect the gems” game. I felt it was a nice option for the club.

I also looked at the Scratch Design Studio for January.  I’ve been looking at the prompts each month since the Scratch Conference in August, hoping to find one that would work for this club.  The current theme is the Year 3000.  I felt it would really bring out their imagination and creativity.

I started out our meeting with a “Happy New Year” and a question for them. Did things seem different now that it was 2019 or did things just seem the same?  I told them that when I was their age, computers weren’t for kids and that 500 years ago books weren’t for kids either.  Then we brainstormed about what the year 3000 would be like.  That was the first hook.

Then I read them the Scratch Design Studio description.  I really liked some of the questions it asks, like what will food be? like or how will we dance?  It sparks the imagination. They shared their ideas and I had a difficult time getting them to not share all at once.

Next, I showed them the project I made about the year 3000.

screen shot 2019-01-08 at 9.18.15 pm

My sample Year 3000 project

The other hook was the text-to-speech extension in Scratch 3.0.  screen shot 2019-01-08 at 9.29.24 pmI had read that some of the tools from Scratch 2.0 – like music and pen blocks – had been moved into the extensions section.  When I went looking, I found the text-to-speech extension.  It is easy to implement and works great.

 

I knew it would be a hit with the Creative Coders, and I was right.  (My only worry would be about the appropriateness of the middle school students – and I let them know, a few times, what my expectations were).

Everyone incorporated text-to-speech in their project and everyone used it appropriately. Whew.

There is not much time in an hour to imagine and create a project but the kids managed to work hard and when I told them they had only 10 minutes to get something ready to share, a few of them revised their big ideas into something manageable.  Two (of ten) said they would finish later.

In the last ten minutes, I showcased the projects they made and added to our January 2019 studio.  We laughed and enjoyed each other’s creativity and imagination.

screen shot 2019-01-08 at 9.43.33 pm

The very funny “So boring” Year 3000.

screen shot 2019-01-08 at 9.47.53 pm

Another very funny text-to-speech Year 3000 project.

I highly recommend trying out the text-to-speech extension blocks and the different voices.  It is a little tricky to have the “text-to-speech” and “say” blocks sync up (like closed-captioning) but is worth it to be able to see and hear the project.

I hope some of them submit their projects to the Scratch Design Studio and I hope next months SDS theme is just as fun.

Happy New Year and kudos to the Scratch team for a great new version!

Fractions to Decimals

I created a Scratch lesson for my 7th grade math class this week. It is a starter project but I wanted the students to have a bit of practice with Scratch before we do a more complex math modeling project in November.

(First a bit of background – I’m student teaching middle school this fall and should have a 5-8 Math teacher certificate by the end of the year.  I’ll be back at my elementary computer lab position after that and I’ll run my code clubs in the winter.  I’m still leading Creative Coders Club at the local public library once a month.)

Screen Shot 2018-10-14 at 7.06.42 PM

The 7th graders have been learning about expressions with variables, integers and rational numbers. For this introductory project I had them create a fraction to decimal converter. Have the user give two integers and use division to give back the decimal.

Screen Shot 2018-10-14 at 7.04.17 PM

Basic code for project (with spelling errors).

I set up a Scratch teacher account with classes for the each section of 7th grade math then put the class invites into our Google Classroom.  This worked well since we were using Chromebooks.  I’m not sure how students who already have a Scratch account would be able to join our Scratch class, but the students seemed okay with making accounts.  I gave a few suggestions on setting up account names.  The only hiccup we had was when they went back to log in a second time, many went through the class invitation again and then couldn’t log in without setting up a second account. (I hope there is a way to remove those extra accounts.)  Adding a direct link to Scratch in our Google Classroom and giving clearer instructions alleviated this problem.

I set up a studio for each class but I gave them the exact same name.  This confused me later when adding projects to the studio I couldn’t tell which went with which class. Luckily you can easily change studio names.

Rational Number Period 1

Rational Number Period 4

After the first day of working on the project, I decided that I needed more formal assessment of this project so I adapted a rubric from the Scratch Ed one here and set up some test cases for the students to use to test their projects.  Testing is an important part of programming.

Students seems engaged and excited to be working in Scratch. I’m pleased with the turnout of completed projects and quality of the work.  There are some missing instructions and spelling issues but even I spelled denominator wrong in my example and a student had to point this out to me. A number of students came in during study hall to work on their projects.  One student who was new to Scratch and our school just had the biggest smile when he learned about the color and whirl effect options.

Screen Shot 2018-10-14 at 7.06.07 PM

New coder excited about Scratch

And one of our struggling students went above and beyond with her project.

Screen Shot 2018-10-14 at 7.05.16 PM

Excellent project

One issue I inadvertently avoided was the fact that Scratch will round decimals to two places in say blocks unless they are inside join blocks.  The Scratch Wiki mention of the Offline Decimal Trick  is the only reference I found in support of this feature.  Fortunately my directions were for student to use the join block to join “The answer is ” and the answer.  This allowed the students to see all of the interesting repeating decimals and weird rounding that appears from converting rational numbers into decimals. I didn’t notice this happenstance until I was helping some students finish at the last minute and we took a short cut for the last line and just put the answer in a say block. It took me a while to figure out what was going on.

Screen Shot 2018-10-14 at 7.03.23 PM

Without the join block, decimals are rounded to 2 places.

Here is the lesson I designed: Decimal Scratch Project If your students are really new to Scratch it might be advantageous to print the first page in color so the students can see where to find the blocks. (I guess I’ll have to update this when 3.0 is released.)

I wondered if any student would try to divide by zero.   Scratch will return the answer “Infinity” in this case which could lead to an interesting math discussion.

Summertime MakeyMakey

Last Tuesday was the fourth and final session of the summer Creative Coding Club at the public library.  It was MakeyMakey time.

The library now has four MakeyMakey devices available to check out! Combined with the eight I borrowed from my school, we had enough for each person to have their own. The library also has Colleen and Aaron Graves’ book 20 Makey Makey Projects for the Evil Genius. I spent some time looking through it ahead of time and ended up building the marble maze project. It had just the right “difficulty to fun” ratio for me.

20180731_103216

I also gathered some supplies, built a couple of pressure switches, and made conductive playdough (I made a gluten-free version with chickpea flour and the kids thought it smelled odd).  I put a few example projects into our Summer #4 Scratch class studio.

Screen Shot 2018-08-07 at 10.37.51 PM

Starter MakeyMakey projects

At the library, we had a fully stocked supply table, thanks to Kathy, and I set up a homemade dance mat (foil and cardboard), the marble maze, and a playdough button piano as examples.

I often find it difficult to introduce and explain what a MakeyMakey device does in a clear, efficient way.  It is much easier to show the MakeyMakeys in action then let the students explore. Three of the students had used MakeyMakey devices before (at our session in May) so they helped me explain to the others.  I did try to hit the key concepts about making a complete circuit or connecting yourself to earth and what to code to get a response.

The best thing about this session was that we had the gift of time.  Extra time to play and explore.  We were just doing this one open-ended thing – playing with MakeyMakey devices and Scratch. The whole time. 90 minutes. It was lovely. We were on Summertime, where you could dive into a project and not worry about constantly moving on to the next thing.

One student had a banana, a potato, a cucumber, and a ball of playdough connected to her music project. Another student made playdough buttons to play his Moonhack project from the previous session.  Another made a 2-player rocket race game.

At one point I walked by two of the girls and they both just had the biggest grins on their faces while playing banana pianos and adjusting their code.

20180731_163829

Staying connected to earth was tricky. I made a playdough ring for my finger but that didn’t work as well as I’d hoped. Other students had other ideas.

One student, near the end, told me he failed. He’s my big idea kid, always exploring the boundaries and testing even bigger ideas. A simple banana piano? Forget it. He thinks up complex ideas and tries them out. He and I both weren’t phased by his declaration, and I didn’t try to help him “be successful”. I just nodded and sat with him for a second in case he wanted to explain where he had failed but he just went on to try some other idea.

My one takeaway on this session was how lovely it was to have time to explore and not hurry off to something else. I enjoyed this slower paced session and they did, too. I have to remember not to over schedule our time and stop worrying about them running out of things to do.

We did stop to share and admire what everyone was doing and then the pizza arrived! Great way to end.

I hope some of these Scratchers check out one of the library’s MakeyMakeys and spend more time exploring the possibilities.