Is it possible to connect multiple light sensors to one port and similiarly control multiple motors through one port only?

(I've tried searching for answers on Google, couldn't find a convincing answer anywhere)

Any help, redirection to literatures, tutorials, answer is appreciated.


  • What do you mean by port?
    – joan
    Commented Jun 24, 2014 at 16:29
  • Sorry for making it ambigious. general purpose input/output (GPIO) pins is what i mean. Commented Jun 24, 2014 at 16:53
  • What kind of light sensors do you have? What do you want to detect? Sometimes you can wire sensors in parallel, so you get a signal if any of the sensors trip (you however can't know which one).
    – Gerben
    Commented Jun 24, 2014 at 18:22

3 Answers 3


You can use a MCP3008 chip to read up to 8 analog sensors via the 4 SPI pins. Have a look at this diagram on upverter. enter image description here

You can also look at my corresponding python code to read the sensors here..

This shows how to read the analog photo sensors over spi using WebIOPi as well as control a stepper motor.


The short answer: no. A GPIO port is a collection of pins. I assume you mean a single pin.

A pin can only take one input or output one value. So you could connect multiple LEDs in series to one pin, but you couldn't connect multiple light sensors to one pin.

The GPIO on the Raspberry Pi can't take analog input like that from an LDR (Light Dependent Resistor). You need an external ADC (Analogue-to-Digital Converter). Often these will include more than one input, so you can connect multiple LDRs or potentiometers.

  • first time with raspberry pi. Trying to learn the ABC of RPi. Commented Jun 24, 2014 at 17:49

Recent Pis have 21 usable gpios. 17 on P1 and 4 on P5.

Generally you need

  • per DC (ordinary) motor: 2 gpios
  • per stepper motor: 4 gpios
  • per servo: 1 gpio

The number of gpios needed per sensor depends on the sensor.

You can use use multiple devices on the I2C buses (the Pi has 2, each of 2 gpios). All sorts of sensors support I2C.

The Pi has no analogoue gpios so you can't connect sensors with analogue outputs to a Pi gpio.

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.