In this post, I’ll show you how to configure your Raspberry Pi so that your programs can run as soon as you plug in your Raspberry Pi to a power source.
Here are the requirements:
- Run a program as soon as the Raspberry Pi is turned on.
Power up your Raspberry Pi, and open up a terminal window.
sudo nano /etc/rc.local
Scroll down the file to the area right after fi but before exit 0. Type:
python3 /home/pi/robot/ball_following_yellow.py &
The format is
python3 /your/file/path/here/filename.py &
Press CTRL-X, and save the file.
Restart your Raspberry Pi.
Your program, ball_following_yellow.py, should run on startup.