Raspberry Pi – 6 LED Python Script

#!/usr/bin/python
#led_alternate.py

import RPi.GPIO as GPIO
import time

delay = 0.2

# Use Raspberry Pi board pin numbers
GPIO.setmode(GPIO.BOARD)

# Setup the channels up as outputs
GPIO.setup(11, GPIO.OUT)
GPIO.setup(12, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
GPIO.setup(16, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)

def initialize():
	#Setup the startup values
	GPIO.output(11,GPIO.LOW)
	GPIO.output(12,GPIO.LOW)
	GPIO.output(15,GPIO.LOW)
	GPIO.output(16,GPIO.LOW)
	GPIO.output(18,GPIO.LOW)
	GPIO.output(22,GPIO.LOW)

# Loop function that alternates the LED's
for y in range (0,10):
	
	initialize()
	GPIO.output(11,GPIO.HIGH)
	time.sleep(delay)
	initialize()
	GPIO.output(12,GPIO.HIGH)
	time.sleep(delay)
	initialize()
	GPIO.output(15,GPIO.HIGH)
	time.sleep(delay)
	initialize()
	GPIO.output(16,GPIO.HIGH)
	time.sleep(delay)
	initialize()
	GPIO.output(18,GPIO.HIGH)
	time.sleep(delay)
	initialize()
	GPIO.output(22,GPIO.HIGH)
	time.sleep(delay)
	initialize()
	GPIO.output(18,GPIO.HIGH)
	time.sleep(delay)
	initialize()
	GPIO.output(16,GPIO.HIGH)
	time.sleep(delay)
	initialize()
	GPIO.output(15,GPIO.HIGH)
	time.sleep(delay)
	initialize()
	GPIO.output(12,GPIO.HIGH)
	time.sleep(delay)
		
GPIO.cleanup()

Raspberry Pi – Static IP Address with WiFi Adapter

In order to make the Raspberry Pi use a Static IP Address with the wireless adapter use the following command to edit the interfaces file:

sudo nano /etc/network/interfaces

The settings below give a Static IP Address of 192.168.1.161, make sure you have connected the wireless adapter and got a connection to your router first.

auto lo
iface lo net loopback

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet static
address 192.168.1.161
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.169.1.254

Obviously these settings are for my network, make sure you use the appropriate settings for your network.