What better way to test a colour sensor then to create a brick sorting robot! After getting my hands on a HiTechnic colour sensor, I first took a stab at creating a robot that could navigate a room and detect colour. There was only one problem, it could not really do what I was hoping for. I was nieve in thinking that I could build this robot and it could detect colours from a distance. After reading the fine print on the provided documentation, I quickly realized that the colour sensor is only capable of reading colours at very close range (~ 1 cm). My bad. Of course, you could still build a robot that uses the ultrasonic or other sensor to get it close to objects, then read the colour… but that’s for another time.
BrickSorter uses this colour sensor to detect the colour of bricks and sort them into a variety of cups. The program is quite simple, gravity and studless beams allow for each brick to slide down the track on its own. when a brick is next, the colour sensor takes a reading (more on this later), the sort motor turns the sort rails to the correct cup, the sort rail motor changes its angle depending if the cup is close or far and finally the kicker motor kicks the brick in motion.
After a lot of fooling around with the cup placement (which seemed to be the hardest part of this project!), I managed to get the sorting pretty much bang on. Of course, the video shows some goofs, but that is mostly due to the small sized cups (its all I had!)… Anyway, I found the sensor to be accurate most of the time, but ambient light still influenced the readings at times and caused for the odd random missorting of a brick. I had to shoot the video about 10 times to get cup placement and sorting goofs worked out.