# Collect digitalRead() in an array

**URL:** <https://discourse.processing.org/t/collect-digitalread-in-an-array/13952>\
**Category:** Processing for Pi\
**Created:** [September 12, 2019, 6:34pm UTC](https://discourse.processing.org/t/collect-digitalread-in-an-array/13952 "2019-09-12T18:34:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephanschulz](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@stephanschulz](https://discourse.processing.org/u/stephanschulz)\
**Post date:** [September 12, 2019, 6:34pm UTC](https://discourse.processing.org/t/collect-digitalread-in-an-array/13952/1 "2019-09-12T18:34:44Z")

</div>

digitalRead() get compared with GPIO.LOW or GPIO.HIGH.  
What kind of array could I set up to collect and compare the state to it?

usually I do:

```auto
boolean[] values = {false,false,false};

if(GPIO.digitalRead(4) == values[0]){
//do something
}

```

but this throws an error

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [September 12, 2019, 9:46pm UTC](https://discourse.processing.org/t/collect-digitalread-in-an-array/13952/2 "2019-09-12T21:46:42Z")

</div>

> [@stephanschulz](#):
>
> GPIO.digitalRead(4)

> **[digitalRead() / Libraries](https://processing.org/reference/libraries/io/GPIO_digitalRead_.html)**
>
> Returns the value of an input pin, which is either GPIO.HIGH (1) or GPIO.LOW (0) You need to set the pin to input by calling pinMode() before calling this …

say use for compare

```auto
if (GPIO.digitalRead(4) == GPIO.LOW)

```

and also that it talks as

> Returns int

possibly

```auto
if (GPIO.digitalRead(4) == 1) {}

```

can work,  
but also your boolean array could work with:

```auto
if (GPIO.digitalRead(4) == int(values[0]) ) {}

```
