If statement with 2 pins

im using arduino Uno and need to use 2 pins at the same time

im using the code from by Tom Igoe's if statements which im editing so that when ports A0 and/or A1 are powered, the on built led goes on, so far i have only managed to get one pin working at a time so how do i get both of them to work?

const int analogPin = A0; // pin that the sensor is attached to const int ledPin = 13; // pin that the LED is attached to const int threshold = 1; // an arbitrary threshold level that's in the range of the analog input

void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize serial communications: Serial.begin(9000); }

void loop() { // read the value of the potentiometer: int analogValue = analogRead(analogPin);

// if the analog value is high enough, turn on the LED: if (analogValue > threshold) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); }

// print the analog value: Serial.println(analogValue); delay(1); // delay in between reads for stability }

|| (or) and && (and)
Not the same as | and &.
http://arduino.cc/en/Reference/Boolean

Example:
if ((apin > something) || (another_pin < something_else)) {
}

Georgebord: im using arduino Uno and need to use 2 pins at the same time

im using the code from by Tom Igoe's if statements which im editing so that when ports A0 and/or A1 are powered, the on built led goes on, so far i have only managed to get one pin working at a time so how do i get both of them to work?

const int analogPin = A0; // pin that the sensor is attached to const int ledPin = 13; // pin that the LED is attached to const int threshold = 1; // an arbitrary threshold level that's in the range of the analog input

void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize serial communications: Serial.begin(9000); }

void loop() { // read the value of the potentiometer: int analogValue = analogRead(analogPin);

// if the analog value is high enough, turn on the LED: if (analogValue > threshold) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); }

// print the analog value: Serial.println(analogValue); delay(1); // delay in between reads for stability }

Check the definition of " if" command. Hint - the next command is processed if the statement / expressions evaluates to true. Now look -up boolean algebra and check out "AND" operator. Waiting for your next post. Cheers Vaclav

Im sorry but im very new to Arduino please could people tell me what needs to be added and where. Thanks

Could you please post your code between "code" tags, as explained here (point 7) ? http://forum.arduino.cc/index.php/topic,148850.0.html

it would be better to post the code you've tried and didn't work . In the code you've posted, the threshold is very very low, the output will be ON as soon as the input is more tha 0,00 Volts !

Serial.begin(9000);

where did you get this baud rate ? Can you set your console at this same rate ?

What do you want to do exactly ? What are you measuring ? etc....

Im using 2 NTE switches so the voltage does not need to be changed i just need it to read pin A0 and A1 at the same time to turn the led on and off.

A0 HIGH =Led on A0 Low=Led off A1 HIGH=Led on A1 LOW=Led off

"NTE switch" is probably going to be too generic to give a reasonable answer. Links, part numbers, pictures are helpful.

If it is a "toggle" style switch, you really don't need to be using analog inputs. You could simply wire it to a digital input, making use of the internal pull-up. There are literally hundreds (if not thousands) of tutorials to do that, including the "button" example in the IDE.

Realizing you're new, but in order to get help, you need to provide specific information and be direct with your questions. Simply asking "please show me where to put things to make my stuff work" is not a specific or direct question.

Georgebord: Im using 2 NTE switches so the voltage does not need to be changed i just need it to read pin A0 and A1 at the same time to turn the led on and off.

A0 HIGH =Led on A0 Low=Led off A1 HIGH=Led on A1 LOW=Led off

then you don't need analog reading, do you ? digital inputs will be enough, an no need for a "threshold" value ;)

we still miss some informations :

how must the led be when A1 alone (or A0 alone) is high ?

The switch is e112765 NTE on a PIC Robot Buggy with wires soldered to it and connected to my arduino. I am planning to use my Arduino to control the PIC ROBOT BUGGY but first of all it has 2 e112765 NTE on it so when the robot hits something it reverses but before I work that part out i need to find out how to turn the led on when either e112765 NTE's are activated (bumped into something) Thanks

Georgebord: connected to my arduino

How?

Are you learning HOW to wire your whatever or how to MAKE one LED light up with two inputs? You do not need to wire anything if you are using Uno. Just power it up and follow the stuff I told you. And than get back to us.