Can you tell me where the syntax error in this code is??
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setup(4, GPIO.IN)
try:
while True:
if (GPIO.input(4) == 1):
print "button pressed"
else:
print "he"
GPIO.cleanup()
it should print button pressed when the gpio pin on my raspberry pi gets power when the button on the board is pressed. but i get an error all the time i run the code in the console running raspbian. most of the errors say "invalid syntax" and than the last codeline of the script.