User Manual

50
Combination
So, this smart car now is smart in three separate features. But, you think only one sensor module
is not enough? Try to combine those sensor modules in one! Here we can show you an
experiment - light following with obstacle avoidance for referece.
When the car runs with the light follower, sometimes it may crash into obstacles when following
the light, and it’s not quite convenient to let the car move back (though we've set the car to
move backward if the array is [1,0,1], it’s hard to acquire these values since the the car is
moving and the light cannot be exactly as required sometimes). So we consider Also, you can
let the car move backwards by a paper board or your foot, which is quite easy.
Check below the program of this example.
Assemble the light follower module and ultrasonic obstacle avoidance module on the car first.
Log into the Raspberry Pi on your computer via ssh, and get into the directory
cd ~/SunFounder_PiCar-S/example
Run the code
python light_with_obsavoidance.py
How it works:
Set the obstacle avoidance as a superior priority than light following: if there is an obstacle in front
of the car, it walk away from the obstacle and back to the track; if not, then the car will keep
follow light.