lilzz
Posts: 411
Joined: Sat Nov 30, 2013 5:27 pm

My Pi goes haywire after this code

Sun Mar 30, 2014 9:21 am

Code: Select all

GPIO = webiopi.GPIO
L1=4  
L2=17 
R1=23    
R2=24 
 setStep(1, 0, 1, 0) 
def setStep(w1, w2, w3, w4): 
    GPIO.output(L1, w1) 
    GPIO.output(L2, w2) 
    GPIO.output(R1, w3) 
    GPIO.output(R2, w4)
After executes the code, setStep, the Pi screen keeps on flashing and wlan0 gone and lose IP address.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: My Pi goes haywire after this code

Sun Mar 30, 2014 10:33 am

Pin 4 is predefined as a clock. To use it, you have to redefine it's function. Available by default are GPIO 17, 22, 23, 24, and 25.
I would just avoid using that pin.

Two questions

1 - what have you got connected to the GPIO pins 4,17,23, and 24?

2 - have you tried the same thing using a shell script?

Code: Select all

#!/bin/sh
PIN=17

# Set up GPIO  and set to output
echo "$PIN" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio$PIN/direction
#turn pin ON
echo "1" > /sys/class/gpio/gpio$PIN/value
sleep 1
#turn pin  off
echo "0" > /sys/class/gpio/gpio$PIN/value
# Clean up
echo "$PIN" > /sys/class/gpio/unexport
Image
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

Return to “General discussion”