Voltage on digital/analoge inputs

Hi,

I'm just starting programming with arduino my first program will be a advanced poeple counter with file/web backups. Only i want to know what the max voltage is of the digital and analog I/O. Only thing i can find aro solutions with a 5v connections. Only my sensor (PhotoElectric Sensor PNP output) . He opperate at 12v (Same as mine arduino) and his output is a 12v. Wat i want to know is if the arduino can handle this or will it blow up.

If not. Does someone know what for resistor xxOhm i need to fix the voltage.

Info:
Ardino Board: Arduino mega 2560 with Ethernet Shield.
Input Adapter: 12v 1A (Powers the board and the Sensor)

Thanks

Can you give us the exact type of that photo sensor (or a link to it)?

pito:
Can you give us the exact type of that photo sensor (or a link to it)?

Here is the specifications of 1 of my sensors but the all have the same output.

sometimes we use also one with a relay with 12v1A on the com.

Those are with NPN (current sink) or PNP (current source) open collectors outputs. So you have to tell us which one you use.

Anyhow, the max voltage for arduino Mega2560 analog input pins is 5V (against ground/GND). So you need to lower/limit the voltage.

I use the PNP (current source) * Told in my first post. And oke the analog inputs are 5v. Are the digital i/o also 5v?

Or is this a solution for the relais sensors.

  • Link the 5v+ with a 100K resistor to a digital input to create a always (HIGH) value and link a GND to the input on sensor trigger to create a (LOW) value.

I use the PNP (current source) * Told in my first post. And oke the analog inputs are 5v. Are the digital i/o also 5v?

Sorry I overlooked that in your first post. Digital are also 5V max.

If the sensor's power source would be 5V then it would be easy. With 12V sensor's power source you may for example to feed the PNP sensor's output through a resistive divider (for example 10k-4k7) to the ground, and from the midpoint of the divider into the analog or digital input. I would put a 5V zener diode into (cathode - analog input, anode - ground) to be safe.
You may play with R2 value a little bit to get 0 - <5V output with your sensor. With longer cables you may consider lower divider resistor's values (for example R1= 1kohm, R2 = 470ohm).
No warranties of any kind :slight_smile:

sens.jpg

Thanks for your reactions i find a solution.

  1. Drop my PNP versions in the trash and use relais versions with GND on com.
  2. Use the inbuild pullup resistor on a digital input find here http://arduino.cc/en/Tutorial/DigitalPins
  3. Connect the relais NO contact to the input so the digital pin goes to LOW on trigger,

Just tested with 12v and this works.

my Testcode:

int sensorPin = 8;
int ledPin = 9;
int sensorValue = 0;

void setup(){
  pinMode(ledPin, OUTPUT);
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);
}

void loop(){
  sensorValue = digitalRead(sensorPin);
  if(sensorValue == 0){
    digitalWrite(ledPin, HIGH);
  }
  else{
    digitalWrite(ledPin, LOW);
  }
  delay(3);
}