This is a very simple robot that uses a simple switch as a sensor and stands on only two wheels with inverted pendulum mechanism.
When the robot is going to fall the motor starts and moves the robot to the direction it is going to fall, so the motor torque about the center of gravity that is higher than the motor makes the robot balanced.
Step 1: Things you need
To make this robot you need following parts and tools:
small electric motor
(or a motor with gearbox)
some sheets of plastic to make bearings and the robot neck
two battery holders
4 AA batteries
one button cell
one SPDT (single pole double throw) switch with a metal lever
one toggle switch for the on/off switchs
Step 2: Motor, Grears, Shaft, and Wheels
In this step you must make a system to moves the robot you can make it easily by adding some gears to a simple small motor, then connect it to a shaft and assemble it two wheels.
You can also use a motor and gearbox.
It does not matter how you make it.
Step 3: Attach robot neck and head
Use glue to attach a sheet of plastic to the motor.
Then put some glue on one side of battery holders and attach them to the top of the plastic sheet.
Step 4: Making the sensor
Solder a button cell to the SPDT switch lever.
Make the nail head hot on a flame and put it on the plastic sheet on the motor in a position that when the robot stands vertically the button cell touches the ground.
Then attach the switch to the robot with glue.
Step 5: Connecting the switch
Solder a wire form positive pole of one of battery holders to the negative pole of the other battery holder and attach the toggle switch to it.
Then attach the other side of the switch to the motor.
Step 6: Wiring
Now it is time to solder the robot wires.
Note that you must solder the wires in a way that robot moves to the direction that is going to fall.
Step 7: Testing
The robot is now completed and it is time to test it.
Put 4 batteries into the battery holders and turn on the switch.
Try to change the position of the sensor to make the robot works better.
If the robot works inverted swap the red and blue wires on the sensor or on the battery holders.