Skip to main content

2. Installing the Code!!!

Part 1: Dependencies

The software relies on other programs to run smoothly. We'll install these now. If not already, connect using PuTTY.

  1. Install Main Dependencies 
    sudo apt install git python3-xyz python3-pip python3-setuptools python3-flask -y
    
    sudo pip install django-templates
  2. Now, we're going to install the official PiCar-V code.
    cd ~/
    git clone https://github.com/sunfounder/SunFounder_PiCar-V.git
  3. Enter the directory
    cd ~/SunFounder_PiCar-V	
  4.  Install smaller dependencies
    sudo ./install_dependencies
  5. VERY IMPORTANT!!! REBOOT THE CAR
sudo reboot now

Part 2: Extra Settings

In this part, we'll enable I2C in the Pi's Config. This allows you to control the motors. Don't worry, this one's quick, and you're almost ready to drive :}}}}

  1. Enter the Raspberry Pi config
    sudo raspi-config
  2. Select interface options by pressing the number for the option using your keyboard.
  3. Enable I2C by moving down to the option and pressing enter.
  4. You can use "esc" to exit.

Part 3: Drivers and Services

If not already using the batteries, connect the Pi to the batteries.

Now, we'll install the drivers for the servos on the car, and we'll write some code to ensure the program runs on boot.

1. Navigate to the PiCar code directory

cd ~/SunFounder_PiCar-V

2. Run the Servo Setup Script - This will move servos in the car, so make sure it is on the floor in an open space.

picar servo-install

3. This next part sets up AutoStart for the remote control program. We'll make a new "service file" so the pi knows to start it after booting.

sudo nano /lib/systemd/system/PiCar.service

4. Paste the following code, then exit.

[Unit]
Description=PiCarServer
After=multi-user.target

[Service]
Type=idle
ExecStartPre=/bin/sleep 10
ExecStart=/usr/bin/python3 /home/pi/SunFounder_PiCar-V/remote_control/manage.py runserver 0.0.0.0:8000

[Install]
WantedBy=multi-user.target

5. Now we'll enable the service with the following commands.

sudo systemctl daemon-reload
sudo systemctl enable PiCar.service

DONE! The next page explains how to connect to the car.