Dies ist eine alte Version des Dokuments!
Erste Erfahrungen mit dem Raspberry Pi sind in Heft 23/2012 der Zeitschrift ELEKTRONIK veröffentlicht worden.
#!/bin/sh
# Blink a LED connected to the Raspberry Pi
GPIO = 4 # P1-07 is GPIO4 on BCM2835
COUNT = 10
i = 0
echo "Hello World from Raspberry Pi"
echo "LED on GPIO4 (P1-07) will blink 10 times"
# Open the GPIO port ('high' direction is output)
echo $GPIO > /sys/class/gpio/export
echo "high" > /sys/class/gpio/gpio$GPIO/direction
while [ $i -le $COUNT ]; do
echo -n "*"
let i = i + 1
echo 1 > /sys/class/gpio/gpio$GPIO/value
sleep 1
echo 0 > /sys/class/gpio/gpio$GPIO/value
sleep 1
done
echo
echo $GPIO > /sys/class/gpio/unexport
echo "Bye."
# Blink a LED connected to the Raspberry Pi
import RPi.GPIO as GPIO
import time
import sys
print ("Hello World from Raspberry Pi")
print ("LED on GPIO4 (P1-07) will blink 10 times")
_GPIO_ = 4 # P1-07 is GPIO4 on BCM2835
COUNT = 10
i = 0
GPIO.setmode(GPIO.BCM)
GPIO.setup(_GPIO_, GPIO.OUT)
while i < COUNT:
sys.stdout.write("*")
sys.stdout.flush()
i = i + 1
GPIO.output(_GPIO_, True)
time.sleep(1)
GPIO.output(_GPIO_,False)
time.sleep(1)
print ("\nBye.")
-- Blink a LED connected to the Raspberry Pi
io.write ("Hello World from Raspberry Pi\n")
io.write ("LED on GPIO4 (P1-07) will blink 10 times\n")
GPIO = 4 -- P1-07 is GPIO4 on BCM2835
COUNT = 10
i = 0
os.execute("echo " .. GPIO .. " > /sys/class/gpio/export")
os.execute("echo out > /sys/class/gpio/gpio" .. GPIO .. "/direction")
while (i < COUNT) do
io.write("*") io.flush()
i = i + 1
os.execute("echo 1 > /sys/class/gpio/gpio"..GPIO.."/value")
os.execute("sleep 1")
os.execute("echo 0 > /sys/class/gpio/gpio"..GPIO.."/value")
os.execute("sleep 1")
end
os.execute("echo "..GPIO.." > /sys/class/gpio/unexport")
io.write("\nBye.\n")
// blink.c
// as modified "Hello World" based on Mike's code below
// Claus Kuehnel (info@ckuehnel.ch)
//
// Example program for bcm2835 library
// Blinks a pin on an off every 0.5 secs
//
// After installing bcm2835, you can build this
// with something like:
// gcc -o blink blink.c -l bcm2835
// sudo ./blink
//
// Or you can test it before installing with:
// gcc -o blink -I ../../src ../../src/bcm2835.c blink.c
// sudo ./blink
//
// Author: Mike McCauley (mikem@open.com.au)
// Copyright (C) 2011 Mike McCauley
// $Id: RF22.h,v 1.21 2012/05/30 01:51:25 mikem Exp $
#include <bcm2835.h>
#include <stdio.h>
// Blinks on RPi pin GPIO 07
#define PIN RPI_GPIO_P1_07
#define COUNT 10
int main(int argc, char **argv)
{
int i = 0;
// If you call this, it will not actually access the GPIO
// Use for testing
// bcm2835_set_debug(1);
if (!bcm2835_init())
return 1;
printf("Hello World from Raspberry Pi\n");
printf("LED on GPIO04 (P1-07) will blink 10 times\n");
// Set the pin to be an output
bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_OUTP);
// Blink
while (i < COUNT)
{
putchar('*');
fflush(stdout);
i++;
// Turn it on
bcm2835_gpio_write(PIN, HIGH);
// wait a bit
delay(1000);
// turn it off
bcm2835_gpio_write(PIN, LOW);
// wait a bit
delay(1000);
}
printf("\nBye.\n");
return 0;
}
[1] Entwickler-Legende baut den 19-Euro-Computer
http://www.spiegel.de/netzwelt/gadgets/raspberry-pi-entwickler-legende-baut-den-19-euro-computer-a-805701.html
[2] Raspberry Pi @ DesignSpark
http://de.rs-online.com/web/generalDisplay.html?id=raspberrypi
[3] Farnell elements14
http://downloads.element14.com/raspberryPi1.html?isRedirect=true
[4] RPi Verified Peripherals
http://elinux.org/RPi_VerifiedPeripherals
[5] RPi Distributions
http://elinux.org/RaspberryPiBoardDistributions
[6] Raspberry Pi Downloads
http://www.raspberrypi.org/downloads
[7] Adafruit Raspberry Pi Educational Linux Distro
http://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/occidentalis-v0-dot-1
[8] Raspberry Pi: Bootvorgang erklärt
http://www.leetperium.de/2012/07/raspberry-pi-bootvorgang-erklart/
[9] Software-Packages in Debian
http://packages.debian.org/stable/
[10] Paket: cppcheck (1.44-1)
http://packages.debian.org/stable/devel/cppcheck
[11] Wiki Ubuntuusers - APT
http://wiki.ubuntuusers.de/APT
[12] Tutorial Installation Debian Linux SSH Server
http://www.tim-bormann.de/tutorial-installation-debian-linux-ssh-server/
[13] Shutter –Screenshot Tool
http://shutter-project.org/
[14] Programmieren auf dem / für den Raspberry Pi
http://raspberrycenter.de/handbuch/programmieren-raspberry-pi
[15] Informationen und Quellcodes zum Beitrag
http://www.ckuehnel.ch/dokuwiki/doku.php?id=raspi_elektronik
[16] Install RPi.GPIO Library In Raspbian
http://www.raspberrypi-spy.co.uk/2012/07/install-rpi-gpio-library-in-raspbian/
[17] C library for Broadcom BCM 2835 as used in Raspberry Pi
http://www.open.com.au/mikem/bcm2835/