LK-RB-Shield
LK-RB-Shield Index 1. Introduction 2. PIN Assignment 3. Setting up the Raspberry Pi 4. Activating the modules 5. Code example: Digital Channels 6. Code example: Analog Channels
Dear customer, thank you for purchasing our product. Please find our instructions below. 1. Einführung The LinkerKit Baseboard-Module allows you to use all the LinkerKit products directly on your Raspberry Pi. You can use the known UART and I2C interfaces aswell as up to 12 digital LinkerKit-products and up to 4 analog LinkerKit-Prdocuts. 2. PIN Assignment You can see a detailed connection assignment in the following picture.
3. Setting up the Raspberry Pi If you are already using the current version if the Raspbian system, you can skip this step and continue with the next one. You can download the current Raspbian Image from the Rasperry Pi Website. With the Win32 Disk Imager -utility you can copy the downloaded image to your SD-Card. Select, as seen in the image below, the image and the device. Then you can start the writing process with Write. If this step is completed, you can put the SD-Card into you Raspberry Pi and continue.
4. Activating the modules To use the baseboard with all ist functions, you need to activate the SPI and I2C modules. The following instruction explains how to activate these modules. Open up, via the console (Ctrl + Alt + T), the Rasperry Pi configuration menu. sudo raspi-config In the opened window, navigate to the menu Advanced Options. Activate the SPI option.
Confirm the next windows with Yes or Ok. Repeat this step with the I2C option. Leave the configuration-menu with Finish and restart your Raspberry Pi. sudo reboot
After restarting your system, please install the latest updates. sudo apt-get update sudo apt-get upgrade Another restart is now required. sudo reboot After restarting, the baseboard is ready to use.
6. Code-Beispiel: Digitaler Kanal The following example shows you how to use the digital connections. For demonstration, we are using an LK-Button1 with an LK-Cable-20 which is also available in our LinkerKit-Series. import RPi.GPIO as GPIO from time import sleep # Initialise button on digital - PIN 22 button = 22 GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) GPIO.setup(button, GPIO.IN, pull_up_down = GPIO.PUD_UP) while True: if GPIO.input(button) == GPIO.HIGH: //Do something else : //Do something else
7. Code-Beispiel: Analoger Kanal The following example shows you how to use the analog connections. For demonstration, we are using an LK-Joystick with an LK-Cable-20 which is also available in our LinkerKit-Series. import RPi.GPIO as GPIO import spidev from time import sleep # Initialise joystick on analogen PINS 0 & 1 joyx = 0 joyy = 1 spi = spidev.spidev() spi.open(0,0) #GPIO.setwarnings(False) #GPIO.setmode(GPIO.BCM) def readadc(adcnum): # read SPI-Data r = spi.xfer2([1,8+adcnum <<4,0]) adcout = ((r[1] &3) <<8)+r[2] return adcout while True: x = readadc(joyx) y = readadc(joyy) print("x: " + str(x) + " Y: " + str(y)) if(x > 1000): print("joystick pressed") sleep(0.1)