Need help with I/O

Hello,

I have a low pass and a high pass filter and I want to use the uno to control a programmable LED strip. I have a hard time understanding how the uno takes inputs from a circuit and sends outputs to the LED strip. Originally, I thought I could do something like:

if(A0 != 0)
{
/Turns pin 13 on for 0.5s

}

if(A1 != 0)
{
/Turns pin 12 on for 0.5s
}

with A0 and A1 connect directly to the low pass and high pass. Both GNDs from the digital and analog sides are connected to the same ground as the LP and HP. Two LEDs are connected to pin 13 and 12 and each LED is in series with a resistor.

Thanks!

darkmatter820:
I want to use the uno to control a programmable LED strip.

...

Two LEDs are connected to pin 13 and 12 and each LED is in series with a resistor.

Are you using a programmable LED strip or are you using two standard LEDs?

if(A0 != 0)

AO is defined in the core (for an UNO at least) as 14. 14 will never ever equal 0 so this would always be true.

if(A1 != 0)

A1 is defined as 15, so same boat here. This will always be true.

if(A1 != 0)

I think you mean if the value on pin A1 is not equal to zero. That would be written as:-

A1_value = analogRead(A1);
if(A1_value != 0) {

A1 is the pin number, you must read the pin number to get its current value.
The same goes for the digital pins 0 to 13. If you want to know the value on say pin 5 then

input5 = digitalRead(5);

Avoid pins 0 & 1 as they handle the loading of code into the Arduino.

Grumpy_Mike:

if(A1 != 0)

I think you mean if the value on pin A1 is not equal to zero. That would be written as:-

A1_value = analogRead(A1);

if(A1_value != 0) {




A1 is the pin number, you must read the pin number to get its current value.
The same goes for the digital pins 0 to 13. If you want to know the value on say pin 5 then


input5 = digitalRead(5);



Avoid pins 0 & 1 as they handle the loading of code into the Arduino.

digitalRead() also works on analog pins as well, so if you’re just checking for HIGH vs LOW, you can use that.

Even when connected to ground through a switch or something, analogRead() sometimes reads a very low value, instead of 0 - so you typically need to do something like if (analogRead(A0) < 10) instead of testing if it’s equal to zero.