This is an observation to see how easy or difficult it is to emulate the behavior of a fly. Since it is technically a bit complicated to built a flying robot we will make it drive around instead.
Let’s start by building the proper electronics. The schematics feature:
A 16F877 as microprocessor as brain Two TC4427A mosfet driver to handle the power requirements of the 9 volts Lego motors A UA7805 voltage stabilizer so the whole circuit is powered by a Lego 9 volts battery box A 1N4007 diode in the ground line to prevent negative power spikes caused by the motor to reach the 5V part of the circuit A 0.1 uF capacitor across the motor to eliminate interference with the RS232 connection to the PC A 470 uF capacitor across the 9 volts power rail to reduce startup and stop power spikes Two LED’s as eyes A ‘human detector’ as aluminum foil proximity detector And of course an RS232 connection to the PC for debugging purposes Apart from that it’s rather straight forward:
In this robot example the food never runs out, so the robot would simply stumble upon the food and then stay there forever. So after hanging about for 100 turn we pretend the food is no longer there (TOUCH = 0) and exit the food loop. In the ideal robot with the ideal sensor chances are the robot would immediately see the food again, but every once in a while it’s an advantage when something doesn’t quite work as it should, and this happens to be one of those moments.
Meanwhile flies are attracted by light (or is that only mosquitoes?), so we need the option to move towards the light. Since the Lego electrical connectors can be mounted in different ways you need to check this routine ‘stand alone’ so to speak to see if it is searching light or avoiding it.
Visit Here for more.