As part of our series on teaching code at home, we ran a presentation at the May LeicesterJS webinar.

We spoke through the learning journey that children could take to develop the skills for writing algorithms, and demonstrated a fun and easy activity to try at home called the "Jam Sandwich robot".

In this activity the adult acts as the jam sandwich robot, and the children have to give the adult instructions to make a jam sandwich. The learning points are that the robot cannot think for itself. It cannot use it's brain to interpret what the instructions mean, so the children need to make sure that the instructions are exact, and in the right order. A very visual way for children to see what happens when there is a bug in their algorithm, which always leads to hilarity!

Working as a team at the LeicesterJS meet, we wrote our code for the jam sandwich robot:

//Start here

function BuildJamSandwich() {

    //TODO Build Jam Sandwich
    WashHands(HAPPYBIRTHDAY.length);

    GetBread();

    if (bread == wrapped) {
        GetBreadOutOfPacket(2);
    }

    GetKnifeByHandle();

    if (knife == dirty) {
        WashKnife();
    }

    if (Environment.IS_BUTTER_ENABLED) {

        GetButter();
        OpenButter(DELID);

        while (butterspreadevenly) {
            GentlySpreadButter(SlicedBread);
        }
    }

    GetJam();
    OpenJam(UNSCREW);

    while (jamspreadevenly) {
        GentlySpreadJam(SlicedBread.surface);
    }

    GetSliceTwo();

    ApplyBread(slice1, slice2);

    DipBreadInJam();
    InsertBreadInFace();

    //Jerome loves Jam
}

BuildJamSandwich();

console.log("Well done! You tried!");
The pseudo JavaScript that we wrote to control our "Jam Sandwich Robot".

Judge for yourself how well it went from the screenshots below!

Ordinarily, I would let the children give verbal instructions for their robot, we used this method to make it more appropriate for an adult audience. The children would also be allowed to fix the bugs in their program and run the jam sandwich robot until they were happy with the results. A great activity to try at home!

Slides Here