RPI Programming

From ElectroDragon Wiki
(Redirected from RPI Code)

Github

Setup

  • raspi-config -> sudo raspi-config -> Interfacing Options -> SPI -> Yes

Packages

Install BCM2835

wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.59.tar.gz
tar zxvf bcm2835-1.59.tar.gz
cd bcm2835-1.59
./configure
make
sudo make check
sudo make install

Install WiringPi

cd
git clone git://git.drogon.net/wiringPi
cd ~/wiringPi
git pull origin
./build

Python2

sudo apt-get update
sudo apt-get install python-pip
sudo apt-get install python-pil
sudo apt-get install python-numpy
sudo pip install RPi.GPIO

Python3

sudo apt-get update
sudo apt-get install python3-pip
sudo apt-get install python3-pil
sudo apt-get install python3-numpy
sudo pip3 install RPi.GPIO


GPIO Wiring

WiringPi

If you do not have GIT installed, then under any of the Debian releases (e.g. Raspbian), you can install it with:

sudo apt-get install git-core

If you get any errors here, make sure your Pi is up to date with the latest versions of Raspbian:

sudo apt-get update
sudo apt-get upgrade

To obtain WiringPi using GIT:

git clone git://git.drogon.net/wiringPi

If you have already used the clone operation for the first time, then

cd wiringPi
git pull origin

Will fetch an updated version then you can re-run the build script below.

To build/install there is a new simplified script:

cd wiringPi
./build

The new build script will compile and install it all for you – it does use the sudo command at one point, so you may wish to inspect the script before running it.

Hardware Config

  • Turn on SPI, IIC option is raspi-config -> advanced option

Reference

Common used commands and program

Command description example 1 example 2
top show current running process - -
chmod change the right of directory or file chmod a+x 111.log chmod -R u+x test4 (change test4 folder and all files, subfolder right)
cp copy file or directory cp -r CharLCD /home/pi (copy folder CharLCD to directly /home/pi, -r to keep construe of the folder)

Raspbian