Mario's Lego Robotics Archive


A non-neural network learning brick sorter. It can be instructed to distinguish among three different colors. The learning process is based on a reward/punishment logic that updates a (rather primitive) knowledge base. It smiles when rewarded and gets sad when punished.


  1. You put a 1x2 brick in either black, red or blue color on a small platform side to a light sensor, and press either the green or red lever to make the robot start the process.
  2. S8 reads the light value for the sensor and decides which bin to drop the brick into. To do this, it evaluates its "knowledge base" (empty at the beginning). If he can find an answer it moves accordingly, otherway it decides to perform a random move.
  3. It moves its pneumatic hand over the platform and takes the brick. Now it moves the hand again over the bin and drops the brick.
  4. S8 stops to wait for your response to its behaviour. You can press either the green lever to say "OK" or the red one to say "WRONG".
  5. If you said "OK", S8 smiles; if you said "WRONG" it gets sad. The information you provided is used to update the KB and make him "learn".
  6. The pneumatic hand returns to its neutral position and S8 waits for another brick.

I used two touch sensors connected to the green and red levers, one light sensor to detect the brick color, one Hall-effect sensor with five small permanent magnets to position the pneumatic hand (the 5 positions are: wait, take brick, bin1, bin2 & bin3). The homebrew Hall-effect sensor may be easy be replaced with a standard Lego touch sensor.
A motor moves the hand, a second one drives the pneumatic valve to open close the hand, and the third one changes the shape of the mouth to make S8 expressive.

The most interesting part of the S8 project was to observe my son and daughter instruct and interact with it, with plenty of comments, suggestions and telling-offs!

Camilla (6) instructing S8.

Sebastiano's (8) turn to play with S8.

Detail of the pneumatic hand. Note the Hall-effect sensor and the magnets (left-top), the light detector (right-centre) and the motor that moves the arm (centre-bottom).

S8 gets sad when you "say" it was wrong.

Copyright © 1996-2013 by Mario Ferrari. All Rights Reserved.

This page is not connected with or endorsed by The LEGO Company. LEGO, LEGO TECHNIC and LEGO MINDSTORMS are trademarks of The LEGO Company.