Code: Select all
#!/usr/bin/python
import RPi.GPIO as GPIO
from time import sleep
# Needs to be BCM. GPIO.BOARD lets you address GPIO ports by periperal
# connector pin number, and the LED GPIO isn't on the connector
GPIO.setmode(GPIO.BCM)
# set up GPIO output channel
GPIO.setup(16, GPIO.OUT)
# On
GPIO.output(16, GPIO.LOW)
# Wait a bit
sleep(10)
# Off
GPIO.output(16, GPIO.HIGH)
Code: Select all
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
espeak "Welcome to Rasberry pi. My I.P. is $_IP. I repeat: $_IP"
else
espeak "Welcome to Rasberry pi. No I.P. found."
fi
According to the LAN9512 datasheet it is possible to reprogram those pins as GPIO. Unfortunately I can't seem to find any information in the datasheet as to how to do thiscanyon wrote: The FDX, LNK and 10M LEDs are hardwired to the USB/Ethernet chip.
Do we just have to put this code into /etc/rc.local and do an sudo chmod +x /etc/rc.local to get it to work or is there any apt-getting to be done first?I had the same problem and solved it through espeak and the audio output by adding the following code to /etc/rc.local:
You have to install espeak first bysimplesi wrote:Do we just have to put this code into /etc/rc.local and do an sudo chmod +x /etc/rc.local to get it to work or is there any apt-getting to be done first?I had the same problem and solved it through espeak and the audio output by adding the following code to /etc/rc.local:
Code: Select all
apt-get install espeak
/etc/rc.local should already have proper permissions. Make sure you use full paths to whatever you want run from there since it doesn't have your user environment.simplesi wrote:sudo chmod +x /etc/rc.local to get it to work
You can use many programming languages to control the GPIO, C (and its variants), shell scripting, PHP, Perl, Python, ARM assembler and more.yogisyaputra wrote:how to use and control GPIO?
are we use c-code or what?
and can you name the programming code?
sorry i'm newbie.
thank you rpdom.rpdom wrote:
You can use many programming languages to control the GPIO, C (and its variants), shell scripting, PHP, Perl, Python, ARM assembler and more.
Have a read of this page http://elinux.org/Rpi_Low-level_periphe ... .28GPIO.29
It describes the GPIO connections and gives a few examples of ways to use them. Then look at the online MagPi magazine for more programs
you might want to have a look at this to start with:yogisyaputra wrote:how to use and control GPIO?
are we use c-code or what?
and can you name the programming code?
sorry i'm newbie.
Return to “General programming discussion”
Users browsing this forum: No registered users and 0 guests