Friday, July 4, 2014

Lesson 59 - Fanbase

Today we were going to recap on geometry. She was busy building animals from some kinda semi-eatable stuff I don't know the name of in any language, so we agreed to start when she was done. Then she started to play with a small battery-operated cooling fan she had tricked me to buy earlier today. I asked her if she wanted to know how the thing works. Guess what.

We started discussing batteries and motors and drew a schematic of the thing. Two batteries and a motor connected as a closed electric circuit. I happened to have a battery and a motor nearby so we tried what happens when you connect them. Rotation! But that wasn't quite convincing yet, so we made a fan out of cardboard. We punched a hole trough it and she connected it to the motor. You can imagine how happy she was when the fan actually worked!




Then I asked what's missing in the picture. And why isn't the fan rotating all the time. And she told me the button was missing from the circuit. Well, I happened to have a Fritzing Creator Kit I got from Reaktor at hand (I was planning to start electronic experiments with her and the Arduino much later...) so we constucted a thingie with a button.




Well, actually a potentiometer. The Arduino board in the picture is not really in use. Just the motor-fan, the potentiometer and the battery. Use the Fritzing kit we were able to connect the thing into a 9 volt battery with fixed wiring. And with the 9V battery the fan was FIERCE. Fortunately the potentiometer let us somewhat tame it. But there was a lot of room for improvement. She wanted a button. I wanted a stabile base for the motor so that no-one would get hurt. We got both.



We used a match box and some playdough to construct a stable "fanbase" for the motor and included a push button into the circuit. And our adjustable 9V push-button fan totally kicked the ass of the lame green 3V fan from the shop (you can see part of it in the photo).

While we were hacking, I was also making some whipped cranberry porridge (I have no idea what you call it in English, we call it vispipuuro). The final phase of the recipe is mixing with a handheld mixer. Like this.


She was really exited to discover that the mixer has the same main parts as our fan: a motor and a switch. She beamed when she told me that it has a power adjustment controller too, just like our potentiometer. Later tonight she pondered whether a vacuum cleaner has the same internal structure. And the electric toothbrush! So many electric devices that have the same simple architecture!




While she was eating, I rewired our concoction into the Arduino board. With minimal programming and some wiring, we got ourselves an automatic fan apparatus that changed rotation speed periodically. Everyone was fascinated and she wanted to start re-coding it so that it would play Twinkle Twinkle Little Star with the motor. In fact, that might be our next task.

Yesterday when hacking with the Arduino myself I had doubts whether electronics hacking would be interesting for a 5 year old girl. No more!

EDIT: It was lingoberry, not cranberry :)

Sunday, June 29, 2014

Lesson 58 - Back to Geometry

There's been some time since our last computer lesson with my daughter. Meanwhile we've been doing a lot of other stuff together, like laying bricks, riding bikes, playing music and making concrete and food. She's asked for a computer lesson a few times, but it's been inconvenient at those occasions so we've ended up having quite a long break. 

And I think it's good. I've been having the feeling that she's pretty much reached the limits of what she can learn at her age, at least with the methods we've used. She's still a 5-year old after all.

Anyway, a few days ago Sanna Salo and her colleagues at Linja published a Koodikoulu (Code School) video on Youtube. My daughter is the narrator on the video :) I think the publication of the video inspired her to ask me for a computer lesson today.

Today my plan was to practice problem solving from the point of view of Geometry. We started with basic shapes. She easily drew a triangle (kolmio in Finnish) and a square (neliö). She wasn't quite happy with some of the lines so I thought her to use a ruler. We also discovered that using an angle ruler (is that the right word?), you can easily make right angles (90 degrees!) and create a nice looking squares. Then she drew me another shape and I asked her if that's a square. She corrected me and told me that it's in fact a rectangle (suorakulmio).



She didn't think that squares are rectangles too, which they in fact are. And we agreed that a rectangle is a square if it's edges have the same length. Then we measured the lengths of her square to be almost exactly 3 centimeters each.

Then I showed on the paper how a turtle would draw a 90 degree circle segment and asked her to show what would happen if it repeated the same trick. She correctly showed how the turtle would complete the second segment. Then we repeated that until a whole circle was covered. And concluded that if you do 4 turns of 90 degrees each, you'll end up with the full circle.




Then we practiced splitting the circle (or a pie!) into 3 segments in the same way. You can see how it went in the picture above. Then we first concluded that if you split a pie into 4 segments, you'll get 90 degree angles. And when asked, she demonstrated me that when you split it into 3 segments, the angles are bigger. But how to calculate the angle?

At this point (30 minutes later or so) she was getting tired and her concentration was slipping. You can see that on the pictures too, I guess. So when we started doing the math (360 / angle) she was eager to get to the computer. So we had the computer calculate the angle of an equilateral triangle.

    360/3
    120

Big numbers for a 5-year old. Yet with my help she was able to parse the result into a word "satakaksikymmentä". 


And we managed to draw the equilateral triangle using Turtle Roy. A lot of giggling was involved. 15 minutes later, she's asleep.

And I think that geometry and turtle graphics are a fun way to learn programming.  Next time we'll hopefully return to the same subject and see how she can decompose a problem and formulate it as a computer program. Then recognize and eliminate duplication using the sequence and repeat commands.

Tuesday, April 1, 2014

Lesson 57 - Careful Planning

I had prepared a new learning environment for this lesson. Such that you can easily implement simple programs like

    var number = random(1,20)
    ask("Guess a number 1-20", guess)
    function guess(answer) {
        if (number == answer) 
          print "Correct!" 
        else 
          ask("Guess again", guess)
    }

Easy eh?

Well, we had gotten past the part of cd'ing to the new directory and listing the files when she suggested we do Turtle Roy instead and write the number guessing game later. So we did some Turtle Roy hacking again.

She wanted to create a "red spiderweb", like the "spider" program we wrote earlier. But red. So she opened the earlierly written program like

    open "spider"

She remembered the command and the quotes quite well.

When we inspected and edited the program a bit and she seemed to understand at least part of it. Then we added the red color and it was like

    let askel=s [fd 100,lt 90]
    let neliö=r 4 askel
    let xz=s [neliö,rt 5]
    let spider=r 72 xz
    clear
    color "red"
    spider

And that was enough for her. I had promised that we'll do some nice extras after the "hard" part so we did. She answered one email, took a fun picture of us using Photo Booth and mailed that to me. Then she downloaded a picture of a rose from the internet and set that as her profile picture. With a little help of course.

Nothing went as planned and that's ok!

Coders do what coders want to do.

Monday, March 17, 2014

Lesson 56 - The Cat and the Invisible Pipe

As promised, today it was a day for nc hacking.

First we discussed protocols and addresses. Like 

  • snailmail protocol, where your address consists of your name, street address and zip etc. 
  • email protocol and email address
  • telephone protocol, where the telephone address is the protocol
  • computers talk with TCP/IP protocol and they have an IP address. 
So, we dug out the IP address of her computer using ifconfig. I explained that we are going to create a "pipe" between our computers to be able to send messages and that we're going to use Netcat (nc) for that. I explained also that in TCP/IP you need to use the IP address and a "port" which is just a number and has to be quite big. We agreed on port 10100. I had her write down the IP and the port.



Then we started Netcat on her machine, and made it "listen to" port 10100.

    nc -l 10100

Such excitement! Nothing happend though. The computer is waiting for the other one to connect.



Then we went to my machine and connected it to hers.

    nc 192.168.1.10 10100

So hack! But nothing happens here either. But when I told her that we can now send secret messages though the INVISIBLE PIPE that we just created, her eyes started to glare. So we started chatting through the invisible pipe (a TCP socket really). It even worked when I took my computer downstairs!

After that we did the same but directed the output from Netcat to a local file, as in


    nc -l 10100 >sala

So now we sent message to each other, so that the recipient could only read the message from the file on their machine. She used vim to read the message I had sent to her.

    vim sala

Now she's replying to me using email. Very internet!

Sunday Coding

Yesterday I took a nap with my 2-year old. Meanwhile the 5-year old had played some Move the Turtle by herself.

Later in the evening she wanted a coding lesson from me. Unfortunately it was quite late and I refused, based on earlier experience on coding lessons just before bedtime.

So she gave a lesson herself to her little sister. They hacked on Turtle Roy together.



It was kinda cute.

Saturday, March 15, 2014

Lesson 55 - In the App Store

Today we tried some iPad apps that teach coding skills. We bought Tynker and Move the Turtle for 5 euros or so, which makes this by far the most expensive lesson ever. But education is worth investing right?

The Tynker app has three different "sub-apps", one of which is Sketch Racer, where you must guide a turtle to draw different shapes. The concept of a drawing turtle is of course very familiar to us from Turtle Roy. And the control mechanism is just like in Scratch. You drag pieces of code together to make up the program that moves the turtle. So it was kinda piece of cake to get started with.



I was a bit worried that the big numbers would be a problem. Like, in the very first problem, you had to issue a "Forward 400" command. But fortunately when I showed her that you can use the rulers to measure the lengths of the edges, she got it at once. And started solving problems.

She got as far as the 7th problem. That was the one where you had to use Repeat for the first time. I guess she'll complete the rest of the challenges Sketch Racer challenges later. Then she played Puppy Adventure that she has earlierly completed on the Hour of Code site. And tried the space adventure thingie but that wasn't her thing.



Next up was Move the Turtle. Once again it's about giving commands to a turtle character. But the UI is not very as intuitive for kids. In the Tynker games and Scratch, the building blocks and the available blocks are always shown and clearly indicate which ones fit together. For instance the Repeat block is U-shaped and suggests that you should drag another block inside it.

Trying apps was fun. Maybe we should start writing app reviews and get rich. Naah, next time we'll go command-line and do some TCP/IP hacking with nc.

Saturday, March 8, 2014

Lesson 54 - Straight Cat

Today we agreed to play some Lightbot together. But when we sat down, she wanted to do the Hour of Code first tutorial instead. Except not. One excercise was enough. Then to Lightbot. One excercise and that was enough. She wanted to do stuff with Scratch.

She selected a nice backdrop from the Scratch backdrop library. Then she started drawing some nice animal characters. The dog and elephant are cute. The cat and the mouse come from the Scratch sprite library.



The coding part was that she made the cat rotate forever. As in


The problem for her was that she couldn't get the cat "straight" again. So I suggested that maybe we should add another script that would stop the rotation when the spacebar is pressed. She was ok with that so I showed her the new blocks she needed and this was the new script.


So, in fact you can react to keyboard input in Scratch and you can stop other scripts from running.

Then I showed her the little game I had coded while she was doing this. She liked it, but quickly found it way too easy. Also she wondered why I didn't include any background music. We agreed that she'll make a similar game herself and adds a background tune too.

Not today though.