# Set more then two analog pins as output

**URL:** <https://discourse.processing.org/t/set-more-then-two-analog-pins-as-output/42737>\
**Category:** Electronics (Arduino, etc.)\
**Created:** [September 10, 2023, 9:27pm UTC](https://discourse.processing.org/t/set-more-then-two-analog-pins-as-output/42737 "2023-09-10T21:27:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![epco](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@epco](https://discourse.processing.org/u/epco)\
**Post date:** [September 10, 2023, 9:27pm UTC](https://discourse.processing.org/t/set-more-then-two-analog-pins-as-output/42737/1 "2023-09-10T21:27:04Z")

</div>

I have a Arduino 8 relay module board that I want to controle via a Arduino UNO that has installed the standardFirmata sketch.

When I test the Arduino and relay board I can control relay 1 to 6 via analog pin A0 until A5.  
I use this test tool: [https://www.pjrc.com/tmp/firmata/readme.html](https://www.pjrc.com/tmp/firmata/readme.html) and set pin 14 until pin 19 to output. When I change the state LOW/HIGH the relay switches on and off.  
In processing I define alle pins as output like so;

```auto
void setup() {
arduino.pinMode(14, Arduino.OUTPUT); //A0
arduino.pinMode(15, Arduino.OUTPUT); //A1
 arduino.pinMode(16, Arduino.OUTPUT); //A2 
 arduino.pinMode(17, Arduino.OUTPUT); //A3
 arduino.pinMode(18, Arduino.OUTPUT); //A4
 arduino.pinMode(19, Arduino.OUTPUT); //A5
}

```

The problem is that only the first two defined pins react. So when I commend out pin 14 and 15. The code below only changes the state of relay on pin 16 and 17 and so on.

```auto
if (btnX == true) {
   
        arduino.digitalWrite(14, Arduino.LOW); //A0
        arduino.digitalWrite(15, Arduino.LOW); //A1
        arduino.digitalWrite(16, Arduino.LOW); //A2
        arduino.digitalWrite(17, Arduino.LOW); //A3
        arduino.digitalWrite(18, Arduino.LOW); //A4
        arduino.digitalWrite(19, Arduino.LOW); //A5
      }
      if (btnY == true) {
        
        arduino.digitalWrite(14, Arduino.HIGH); //A0
        arduino.digitalWrite(15, Arduino.HIGH); //A1
        arduino.digitalWrite(16, Arduino.HIGH); //A2
        arduino.digitalWrite(17, Arduino.HIGH); //A3
        arduino.digitalWrite(18, Arduino.HIGH); //A4
        arduino.digitalWrite(19, Arduino.HIGH); //A5
      }

```

Is there a reason why I can not set more then two analog pins to an output like in the test tool?

---

<div class="post-metadata">

**Author:** ![sterretje](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@sterretje](https://discourse.processing.org/u/sterretje)\
**Post date:** [September 11, 2023, 7:26am UTC](https://discourse.processing.org/t/set-more-then-two-analog-pins-as-output/42737/2 "2023-09-11T07:26:45Z")

</div>

How do you power the relays on the relay board? If you power them from the Uno’s 5V pin, you probably are running into power limitations.

Trim your Processing sketch to e,g,

```java
if (btnX == true) {
  arduino.digitalWrite(14, Arduino.LOW); //A0
}

if (btnY == true) {
  arduino.digitalWrite(14, Arduino.HIGH); //A0
}

```

Test (you said it works).

Change 14 to 15 and test.  
Change 15 to 16 and test.

Test all pins; do they all work when controlling a single relay? If no, I do not know what the problem is; if yes, I’m sure it’s a power issue and you will need a dedicated power supply for the relays on the relay board.

See e.g. the diagram at [8-channel relay board help (only some working?) - #18 by xl97 - Project Guidance - Arduino Forum](https://forum.arduino.cc/t/8-channel-relay-board-help-only-some-working/981034/18)

![a34d6b0cb82bd1e90e91cf0af1918a783dce6404](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/f/3/f37ea8a6c262360fe858c5fc9b693719821023bd.jpeg)

---

<div class="post-metadata">

**Author:** ![epco](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@epco](https://discourse.processing.org/u/epco)\
**Post date:** [September 11, 2023, 7:56am UTC](https://discourse.processing.org/t/set-more-then-two-analog-pins-as-output/42737/3 "2023-09-11T07:56:57Z")

</div>

I trimmed the code and it seems there was a conflict that blocked the HIGH/LOW signal.  
Thanks for your response

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [September 11, 2023, 11:34am UTC](https://discourse.processing.org/t/set-more-then-two-analog-pins-as-output/42737/4 "2023-09-11T11:34:22Z")

</div>

> [@epco](#):
>
> seems there was a conflict that blocked the HIGH/LOW signal.  
> Thanks for your response

Hi

I think that changing A0 to A5 pin mode is restricted to standardFirmata sketch.

Here is useful video

[![](https://img.youtube.com/vi/606ceAvWvPw/maxresdefault.jpg "Processing: Step 3, Arduino and Firmata") ](https://www.youtube.com/watch?v=606ceAvWvPw)

Play with this example

> <https://github.com/firmata/processing/blob/master/examples/arduino_output/arduino_output.pde>
