I am a beginner in Raspberry PI robotics and I tried to write a code that turns an AC motor on and off. The code:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.OUT)
GPIO.output(7, True)
time.sleep(1)
GPIO.output(7, False)
time.sleep(1)
GPIO.cleanup()
I tried even in a for loop, and it gives me the Runtime Exception. I made sure every pin is connected correctly, and even tested the motor with the 5V pin and Arduino. Everything seems ok, but the code doesn't work. There is no error in the code posted up, it doesn't work. The sleep function work (program waits 2 seconds), but the GPIO pin doesn't turn on. Why?




BOARDpin layout, are you sure you've got it connected to the correct pin?BCM7 isBOARD26. Also, you're not turning the pin on and off, you're turning it on and on. - stevieb