led counter


need help, newbie…
first project attempt

I have two Pir sensors and 10 leds
5 for each sensor

what I want:

Detect movement sensor 1
high led 1
detect movement again in sensor 1
high led 2 (led1 keeps high)
and so on

same logic for the sensor2

the code tried so far :~

int pinArray[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
int count = 0;
int sensors1 = 12;
int sensors2 = 13;
int val = 0;
int val1 = 0;

void setup() {                
for (count=1;count<12;count++) {
  pinMode(pinArray[count], OUTPUT);
pinMode(sensors1, INPUT);
pinMode(sensors2, INPUT);

void loop() {
val = digitalRead(sensors1);
if (val == HIGH){ 
  for (count=0;count<6;count++) {
    digitalWrite(pinArray[count], HIGH);

val1 = digitalRead(sensors2);
if(val1 == HIGH){
  for (count=7;count<12;count++) {
    digitalWrite(pinArray[count], HIGH);

if(count == 6, HIGH || count == 11){
  digitalWrite(pinArray[count], LOW);

If you want to figure out what your program is doing with some Serial.prints, it is good that you excluded pin zero from having it's pinMode set, but you should do the same for pin one too.

changed array
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

still having trouble, all LEDs light up, and only the pin 7 reacts to Pir

You also want to look at the state change detection example. Your code, now, will light up all the LEDs in one set whenever the sensor IS high, not BECOMES high.

if(count == 6, HIGH || count == 11){

Study this carefully. It is wrong.

so i need to set current state of the Sensor?
this way he lights one by one? keeping the previous high

I saw this example, I can´t understand too well

how can I apply to the sensor

so i need to set current state of the Sensor?

How can you? It's an input device.

You need to detect when it changes state, from no motion sensed to motion sensed, so you can count the number of times that has happened. You light a different number of LEDs, based on the count.