I want to give signal via PLC to Raspberry Pi and when the raspberry pi gets that signal, it should run the python script and when the python script execute properly and cycle is completed, it should wait for the other signal from PLC to again run the same script and same cycle should go on.

here is my snippet:

import cv2
import numpy as np
import RPi.GPIO as GPIO
import time
from picamera import PiCamera
from PIL import Image
camera = PiCamera()
RedLedPin = 36
GreenLedPin = 38
PLC_Input_signal = 37
GPIO.setup(PLC_Input_signal, GPIO.IN)
GPIO.setup(RedLedPin, GPIO.OUT)
GPIO.setup(GreenLedPin, GPIO.OUT)
GPIO.output(RedLedPin, GPIO.HIGH)
GPIO.output(GreenLedPin, GPIO.HIGH)
if (GPIO.input(PLC_Input_signal) == GPIO.LOW):
    camera.resolution = (4056, 3040)
    print('Signal Not Received')
GPIO.input(PLC_Input_signal) == GPIO.HIGH

but when i am providing 5v supply to gpio pin i.e. as defined in code pin 37, it is not working accordingly. please help me out. please note that gpio is active low pin which gpio.low turns on the power while gpio.high turns off the power

please help me out

  • The GPIO pins are not 5V tolerant. You can damage the pin or the Pi by doing so. Jul 19, 2022 at 4:35
  • @SteveRobillard can you suggest what is the error then
    – dsp
    Jul 19, 2022 at 5:23
  • 1
    ?? One error is as Steve explained - the GPIO pins are designed to handle 3.3V... NOT 5V. If you're looking for someone to debug your code, you might have better luck at StackOverflow.
    – Seamus
    Jul 19, 2022 at 6:25

1 Answer 1


An experienced developer would approach your issue (which is unclear) on a step by step approach .

  1. Detect a signal
  2. Write code to do something with signal
  3. Next step.

Start with 1

  • @Gil why are you addressing this to me? Nothing to do with my answer.
    – Milliways
    Aug 19, 2022 at 22:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.