Can i put a solenoid on the arduino
but as an analog and also digital in the same time?
Usually not directly - will need a transistor to sink current thru the solenod coil to actuate it.
I don't know what you mean in the 2nd part of your question. Usually one would just use a digital output to turn on the drive transistor. analogWrite(0) and analogWrite(255) would work also, but why would you? You would not PWM a solenoid usually.
A solenoid as I understand the term is a device that, when a current is passed through its coil, moves an output arm or shaft. As such it is usually a digital device but I could envisage a device where the output movement was proportional to the input voltage, so would be analogue.
Either way the current available from an Arduino pin is very limited. Have you got a link to the device that you have in mind ?
If you use a PWM pin on the Arduino and drive it with analogWrite() then if you output either 0 or 255 it acts a digital output being either fully off or fully on respectively.
+1 to the above replies; I would add that you should treat it like a motor or relay (they are all similar; an inductive coil that generates a magnetic field when current is passed through.) and include a clamping diode so the transistor doesn't get hit with a voltage spike when the solenoid gets turned off.
I would like that my ardeuino read the solenoid in the analog and digital write if a condition is accomplished
Jhjh:
read the solenoid
Solenoids aren't sensors.... what do you mean?
What you mean by a solenoid and what I mean by a solenoid is obviously not the same. Please provide a link to the device that you want to use.
http://addison-electronique.com/catalog/product/view/id/6303/s/090145-solenoid-24-vdc/
on this one i am able to read the tension on an analog read but i want at the same time
that like when tension is = to 0.04 that he digitalwrite High to 2sec
Sounds like you need an analog pin to read a voltage (what range of voltage?),
a digital pin to drive a transistor/diode to switch the solenoid, and code to link
the two. That solenoid doesn't seem to say what current it needs.
i am able to read the tension on an analog read
From where? I only see 2 wires. Is there another sensor somewhere?
Jhjh:
http://addison-electronique.com/catalog/product/view/id/6303/s/090145-solenoid-24-vdc/on this one i am able to read the tension on an analog read but i want at the same time
that like when tension is = to 0.04 that he digitalwrite High to 2sec
You seem to have much more information than is given on the page linked to. Where did you get the information ?
this type of solenoide can give you the voltage and
I want him to give me the voltage and when it reach 0.04 to digital write it
this type of solenoide can give you the voltage and
I want him to give me the voltage
Are you trying to measure back EMF?
Jhjh:
this type of solenoide can give you the voltage
No it can't.
Unless you can explain more then you are not understanding what a solenoid is.
ok
I tried alredy this solenoide can give you the voltage back when a magnet pass near to him.
And i tried i could digitalwrite him high
but could i do those two things on an alaog pin
so when he read 0.45 tension he activate the solenoide?
It seems that you want to read the voltage across the solenoid coil and when it reaches 0.45 (what units ?) you want to activate the solenoid. Is that right ?
To activate that solonoide you need to put 24 V across it. This will then damage any input connection to the arduino. Therefore you will have to fit a voltage divider to go from 24v to 5V so that is a 5:1 division ratio. This will then reduce the sensitivity of the input.
So you need a 24V supply, a transistor or FET , a base / gate resistor and two resistors for a potential divider as well as two arduino pins with at least one of them an analogue pin.
but can i at the same pin be as output and input
Not at exactly the same time - but you can alternate back & forth, and change very quickly.
Look at the Ping example in the IDE for an example of a pin being used as an input and an output in the same program.