Hi!
Help how to read read two analog inputs and output to digital output when A0 and A1 is opposite..
A0 have three state and A1 two state..
When A0 <360 and A1 >720 =digital high
When A0>720 and A1 <320 =digital high
When A0 from360 to 720 digital low
Yes I have searched but I am beginner and need help to loop code
So post what you have got so far. Remember to use the </> ICON when posting code.
Two comparisons may be made in an if statement and combined with a logical and, the && operator.
So
if(variable1 > 50 && variable2 < 45) { // do stuff
int analogPin = A0; //analog input 0
int analogPin1 = A1; // analog input 1
int val0 = 0; // variable to store the value read of a0
int val1 = 0; // variable to store the value read of a1
int ledPin = 13; // LED connected to digital pin 13
void setup()
{
Serial.begin(9600); // setup serial
pinMode(ledPin, OUTPUT); // sets the digital pin as output
}
void loop()
{
val0 = analogRead(analogPin); // read the input a0 pin
val1 = analogRead(analogPin1); // read the input a1 pin
if (val0 > 700 && val1 < 300)
{
digitalWrite(ledPin, HIGH);
}
else if (val1 > 700 && val0 < 300)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
Serial.println(val0); // debug value
}
if (val0 > 700 && val1 < 300)
These are not the values you specified.
Rather than
val0 = analogRead(analogPin); // read the input a0 pin
val1 = analogRead(analogPin1); // read the input a1 pin
it would be safer to do
val0 = analogRead(analogPin); // read the input a0 pin
val0 = analogRead(analogPin)
val1 = analogRead(analogPin1); // read the input a1 pin
val1 = analogRead(analogPin1);
as the first reading on a different pin may be "contaminated" by a residual voltage from the previous pin. By duplicating the analogRead()s the first value on each pin is discarded.
...R
as the first reading on a different pin may be "contaminated" by a residual voltage from the previous pin.
But is is only needed if the impedance of the source driving the analogue inputs is high, that is in excess of 50K.
The problem here is you have not told us what circuit you have.
You have also not told us what results you got from this code and what the debug output is.
glas lcd tn positive damaged...now from lcd pins to arduino from arduino to segment led ..
But damaged lcd have common segments and now I want separate segments to each...
2 backplane to a0 and a1 and segment pin to digital input and two digital output after separating-led1 and led2--
led1 is high when common1 is high and segment12 is low or common1 is low and segment12 is high
led1 is low when common1 is low and segment12 low or common1 is high and segment12 is high
led1 is low when common1 1/2(512) and segment12 low or common1 1/2(512) and segment12 high
led2 is high when common2 is high and segment12 is low or common1 is low and segment12 is high
led2 is low when common2 is low and segment12 low or common1 is high and segment12 is high
led2 is low when common2 1/2(512) and segment12 low or common1 1/2(512) and segment12 high
For me, Reply #8 is completely meaningless. It seems to have nothing to do with any of the earlier stuff in this Thread.
...R
nokialkatel:
Input on arduino
They must charge by the character wherever you connect to the internet.
...R
@nokialkatel - Please read this:-
How to use this forum
Because your posts are totally meaningless. Reading this will help you ask a question that is not pants.
Grumpy mike you helped me on post 3 ..thanks
On post 7 you asked about my circuit..my circuit is on post 8 and in post 10 att. Screenshots of inputs..
Com1 is on analog0 and com 2 is on analog1..segment is on digitalread pin8..
My attached code on post4 is just ex.on how to compare two inputs..not final code just try code...
Any help to my is help (I am newbie and ned just direction on how to solwe this like on post 3...thanks
In reply #8 I said:-
The problem here is you have not told us what circuit you have.
You have also not told us what results you got from this code and what the debug output is.
The posts #8 and #9 in no way address these requests.
We need to see schematics, we need to know what happened when you ran that code. We need some sort of words that say what the posts are all about. They came across as meaningless, with no context and with not addressing the questions.