When i execute with sudo python3 program.py and press de switch 1 throws the next exception:
Traceback (most recent call last):
File "main.py", line 21, in <module>
RuntimeError: You must setup() the GPIO channel first
import RPi.GPIO as GPIO
# initial config for gpio ports
# input switches
switch1 = 22
switch2 = 23
switch3 = 24
GPIO.setup(switch1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(switch2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(switch3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# main loop
print ("Taking picture...")
with picamera.PiCamera() as camera:
camera.resolution = (1280, 720)
print ("Picture takeng...")
print ("Taking video...")
The error is telling you that you have not set the pins to work as input and, when you try to access them as so, it fails. I had a similar problem and as far as I see it it should work (you are setting the pins after all).
GPIO.setmode(GPIO.BOARD). You will also have to change the pin numbers to the physical ones (yours would be 15, 16 and 18).
I still don't know why, but it did the trick on my code.