Lesson 6 – Tamagotchi!!

Learning Outcomes









Words to learn for this lesson are:


So this lesson, we’ll be making an interactive pet – much like the famous Tamagotchi (in fact if you’ve got a microbit in the 3D printed case, it already looks like a virtual interactive pet)!

Have a think.  In your book, note down how:

  1. The micro:bit sensors could be used for “looking after” the pet (feeding, playing, exercising)
  2. The micro:bit could give “haptic” feedback (happy, sad angry, ill, hungry etc…)


Look at the >>Pseudocode here<<.  Is this python?  Why is it written this way?
In your book, explain what the code is doing.

Now, just like the previous 2 lessons,  You’ll need to find your code >>here<<  and very very carefully get it working in the micro:bit micropython editor.  Be very careful typing that code.  Check your indentation, and make sure you are being accurate with camelCase.


  1. This code is only really keeping your Tamagotchi fed.  How about adding code to make the Tamagotchi “Bored”, and try to get it happier by exercising it (Think:shake)?
  2. Quite difficult… Maybe it could  get poorly now and then (look at the random number in the previous lesson).  It needs medicine!  Quick!!
  3. Comment all your changes, and make sure there is a copy for your books.


How can this program be improved?  Write down a few ideas to extend your program.  Where would you change the code?  How would you make it more interactive?