Sunday, January 25, 2015

Lesson 63 - Raspberry

A Raspberry Pi came from the mail and has been lying on the kitchen table for a while. 

It's essentially a little, dirt-cheap computer that can run Linux and has HDMI output, LAN connector and a couple of USBs. The interesting part for me is that you can easily plug in a Wifi adapter and you can use the GPIO pins to control electronics like LEDs and motors. And when I say motors I mean ROBOTS. Autonomous, Internet-connected ROBOTS.

I guess I was nibbling this skeletal little computer when my daughter asked me to have a "computer lesson" again. We discussed the Raspberry a little, but then went to draw the computer on a whiteboard. This is what it became. 



It's 95% drawn and written by her.

We started from CPU and its central role as the part that runs her programs. Then to RAM from where the CPU reads its instructions. And then, what do you think happens to the stuff in RAM when you unplug the power cords (drawn in the diagram). Her answer was funny, but I unfortunately forgot it already. Then we went on to persistent storage, or "hard disk", display, keyboards, USB connectors and stuff. She enjoyed drawing a lot!

Then we took a look at the Raspberry that looked like this.


All the parts are neatly exposed on this computer, ain't they! We identified the parts in her diagram that were currently missing in the Raspberry and marked them with red magnets. Then we added an SD card as the "hard drive" of the computer.

I installed a Wifi dongle (took me a while, I admit), created her an user accound. Later I told her that even though we don't yet have a keyboard and a display for the Raspberry, she can use it via network. She was quite enthusiastic to try it so we logged in using SSH using her own computer.



Once there, we decided to create a file using vim (which I pre-installed of course). As usually it took quite a while to select a suitable name for this new file, especially when she had to negotiate it with her baby sister. Eventually she kinda pulled rank and decided to name the file after herself. The naming debate had exhausted her though and she quit before even starting to think about what the file should contain.

Fun day! I especially recommend the drawing part. Afterwards I wrote a little Python program that blinks a led. Maybe we'll create a Raspberry robot soon. I have motors and stuff you know.

Tuesday, January 6, 2015

Frozen Dragons

Yesterday we had a Movie Night with our family. We watched the film Frozen featuring the princesses Anna and Elsa who seem to be the current idols of our daughters.

Today my bigger girl made yet another Christmas card with Scratch and then went on to code.org to discover that Anna and Elsa are now featured as the first tutorial! So now she's drawing beautiful drawings on the ice by coding. It's a very nice tutorial indeed, but depends very much on angles. Like, you need to do an 120 degree angle there and a 90 degree angle there. Fortunately you can pick the angles from a dropdown...

Another nice thing we've been playing lately is Dragonbox that's not directly related to programming, but teaches algebra instead. Even our 3-year old is able to solve simple math equations!



While the 3-year old was solving equations, the 5-year old built a robot out of Lego Mindstorms bricks. I guess we'll have to do some robot programming soon.

Monday, November 24, 2014

Go Candy Robot!

Today I visited the Koodikerho (Code Club) at a local school in Espoo, Finland, hosted by Marko Klemetti from Eficode. Marko has been doing these code clubs for some time already and it shows! He has a really nice relationship and a laid-back attitude with the 3rd to 6th graders attending the club.

There were two 45 minute sessions, one for the 3rd / 4th graders and one for the 5th / 6th graders. For the younger ones we did a Candy Robot exercise, where the kids write down instructions for the Candy Robot that has to pick and sort candies from a bag into 4 cups. If it succeeds to place 2 candies in each cup, the kids get the candy. The challenge is that the robot only understands a very limited number of commands and takes everything literally.




The Candy Robot exercise worked extremely well. It took 2-5 iteration for each team of kids to get to the correct solution so that they can eat candy and play with iPads. It was fun and taught the basics of programming quite well.

With the 5th / 6th graders we started the Codecademy Javascript program on which I have mixed feelings. On the other hand, it teaches a language that's really relevant today; it's the language of the Web. However, the Javascript program on Codecademy is in English only and has quite verbose text sections that are tough especially for the 5th graders. Also, I think it's a bit boring. Nevertheless, the kids did surprisingly fine. It was really tough, but they mostly kept focused and asked a lot of good questions. I hope this builds their skills faster than it kills the joy in programming :) Soon enough, they should be able to build their own programs in Javascript.

Later today, I tried the Candy Robot exercise with my 5-year-old at home. Not surprisingly it was a lot tougher for her and she required a lot more help than the kids at school. For a while she got frustrated but eventually, with enough help, she came up with a working program. Maybe I should have used real candy with her too, instead of the Hama beads...

Her program looked like this, before we gave up on actually writing everything down.




But what really made the night for us was the exciting game of Go, which was the first one for her. I only gave her easy time for the very beginning of the game until I discovered that she'll kick my ass. She was brilliant and ruthless and took no prisoners.

Sunday, November 9, 2014

Lesson 62 - Basic Basic

Today I refreshed my Commodore 64 programming skills by reading the C64 Wiki. Meanwhile my daughter was playing some games on the net. It took just a little while to for her attention to switch to what I was doing. I guess the animated bird was the selling point. 

A fun thing about the Commodore Basic is that if you want a delay, you do it with a for-loop:

    FOR X=1 TO 300:NEXT

Anyway, she wanted to change my "waves" program to one that would print her name all around the screen. It took a sec to get used to the way programs are edited on this old machine. 

For instance, you always edit in the overwrite mode. And you have only 2 arrow keys, so that you have to the SHIFT key to be able to move to all directions.

Yet, she made it! So her first BASIC program looks like this.



In case you wonder what the semicolon does, it prevents the otherwise automatic line-feed.

And managed to save it too. Now she's looking for the disc that says "Bubble Bubble".

Wednesday, November 5, 2014

Bubble Bobble

Yesterday I mentioned that I have a bunch of old computers in the storage room and promised to show them to my girl. I also promised that we'll look inside them. So today, when she was a bit reluctant to do her violin homework I promised that we'll have a look at the old computers after she's done with the violin. She started playing the violin immediately!

Meanwhile I dragged an old Commodore 64 from the storage room. Then we assembled it together. You have to plug in the power cord, the floppy disk drive (the infamous 1541 unit) and the joysticks (Tac 2 of course). Finally you have to plug the s-video and audio cables to the TV. I asked her whether she thinks if you can connect to the Internet with this device and she guessed right. The net didn't exist when this machine was designed.

She wanted to see how this computer is programmed so I showed a simple basic program involving the easily accessible graphical symbols on the keyboard.



What a beautiful bird! Then I started trying to do some for-loops and animations but failed miserably. The girls grew anxious and wanted to see (or even code!) games. So I gave up with the Commodore Basic and found the Bubble Bobble floppy disk. It was fun to see how she struggled to insert the disc into the disc drive. With some instructions, she succeeded of course.

Then it was time to

    LOAD "$", 8
    LIST

And see what's on the disc. Bubble Bobble seemed to be there as promised on the cover. So

    LOAD "BUB*",8,1

It did take quite a while to load it of course and we had a brief discussion on what old computers are like. I had to admit that you never know whether the game will eventually load and work as expected. But in a couple of minutes the game had loaded!

She typed

    RUN

And then some weird ASCII graphics happened and in a while we were playing Bubble Bobble. And in fact, the girls are still playing it and they love it. You have to appreciate a game that ages this well!



Maybe we'll get to Commodore Basic coding next time. It's pretty fun indeed, with the graphical symbols easily available on the keyboard. The downside is of course that it's pretty verbose and the editor is weird. But she already manages vim so it shoulnd't be an issue. Good times!

Tuesday, October 21, 2014

Koodikirja





I just published the first chapter of my online coding book Koodikirja (in Finnish).

This is something I've been hacking on every now and then from the start of this year or so. It teaches some basic computer programming using my Turtle Roy learning environment.

Check it out! And watch out, this is only the beginning!

Monday, October 6, 2014

Turtles and Tanks

Last weekend we visited my friend in the beautiful town of Loviisa and her lovely daughter Amanda and played some board games.

We started with Robot Turtles, that I covered in my previous posting too.

The thing was, they had two cats. So we played Robot Turtles with Amanda while my daughters chased and petted the cats around the house. Turned out Amanda liked the turtle programming game a lot and quickly hacked how to capture the diamond with a "program" that's a sequence of moves. She also learned how to debug: try something, run it, then try again. 

Many times she decided to start her somewhat complected program from scratch instead of trying to fix it. That's what a programmer sometime has to do!

She also learned to use the LASER card to melt icy obstacles into harmless ponds of water.

Then something unusual happened.


Her turtle was surrounded by tanks.

Guess what she did?

Well, she calmly constructed a program that made her turtle eliminate all of the tanks with LASER. And she succeeded with her first try too. Each tank exploded with a huge BOOM!

So we switched to a hex board and gave her seek and destroy missions. Tanks a plenty were destroyed. 

Meanwhile my girls had messed Amanda's room quite badly. I ask Mila to have a look at what Amanda was doing and the joined their forces to take out a platoon of tanks with their flawless programs before we had nachos.

Who said girls can't destroy tanks?