PIR sensor with running light

Hey, I wanted to display a light run with the help of a PIR sensor.

I managed to light up an LED.
Code:
int pirPin = 2;
int ledPin = 3;

void setup () {

pinMode (pirPin, INPUT);
pinMode (ledPin, OUTPUT);
}

void loop () {

int s = digitalRead (pirPin);
digitalWrite (ledPin, s);

for my LED light run

int ledPins [6] = {2, 3, 4, 5, 6, 7};

        void setup ()
        
       {
         
           pinMode (ledPins [0], OUTPUT);
           pinMode (ledPins [1], OUTPUT);
           pinMode (ledPins [2], OUTPUT);
           pinMode (ledPins [3], OUTPUT);
           pinMode (ledPins [4], OUTPUT);
           pinMode (ledPins [5], OUTPUT);
          }
        
        void loop ()
        {
        
        digitalWrite (ledPins [0], HIGH);
        delay (500);
        digitalWrite (ledPins [0], LOW);
        delay (500);
        digitalWrite (ledPins [1], HIGH);
        delay (500);
        digitalWrite (ledPins [1], LOW);
        delay (500);
          digitalWrite (ledPins [2], HIGH);
        delay (500);
        digitalWrite (ledPins [2], LOW);
        delay (500);
          digitalWrite (ledPins [3], HIGH);
        delay (500);
        digitalWrite (ledPins [3], LOW);
        delay (500);
          digitalWrite (ledPins [4], HIGH);
        delay (500);
        digitalWrite (ledPins [4], LOW);
        delay (500);
          digitalWrite (ledPins [5], HIGH);
        delay (500);
        digitalWrite (ledPins [5], LOW);
        delay (500);
        }

I wanted to combine the two and the code came out:

int ledPins [6] = {2, 3, 4, 5, 6, 7};
int pirPin = 8;

        void setup ()
        
       {
           pinMode (pirPin, INPUT);
           pinMode (ledPins [2], OUTPUT);
           pinMode (ledPins [3], OUTPUT);
           pinMode (ledPins [4], OUTPUT);
           pinMode (ledPins [5], OUTPUT);
           pinMode (ledPins [6], OUTPUT);
           pinMode (ledPins [7], OUTPUT);
          }
        
        void loop ()
        {
         int s = digitalRead (pirPin);
        digitalWrite (ledPins, s);
     if (digitalRead (pirPin) == HIGH);
        digitalWrite (ledPins [2], HIGH);
        delay (500);
        digitalWrite (ledPins [2], LOW);
        delay (500);
        digitalWrite (ledPins [3], HIGH);
        delay (500);
        digitalWrite (ledPins [3], LOW);
        delay (500);
          digitalWrite (ledPins [4], HIGH);
        delay (500);
        digitalWrite (ledPins [4], LOW);
        delay (500);
          digitalWrite (ledPins [5], HIGH);
        delay (500);
        digitalWrite (ledPins [5], LOW);
        delay (500);
          digitalWrite (ledPins [6], HIGH);
        delay (500);
        digitalWrite (ledPins [6], LOW);
        delay (500);
          digitalWrite (ledPins [7], HIGH);
        delay (500);
        digitalWrite (ledPins [7], LOW);
        delay (500);
        }

the problem is i am getting this error message
In function 'void loop ()':
21:36: error: invalid conversion from 'int *' to 'uint8_t {aka unsigned char}' [-fpermissive]
1: 0:
135: 6: note: initializing argument 1 of 'void digitalWrite (uint8_t, uint8_t)'

exit status 1

I really don't know what to do next and hope for a few tips

if (digitalRead (pirPin) == HIGH);

Oops

You can't write a single value to an array like that -
It's hard to see what you intended.

Please remember to use code tags when posting code

Hi, @kingatze
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

We need to see your code in code tags, this will put it in a scrolling window that is easier to read.

Thanks.. Tom... :grinning: :+1: :coffee: :australia:

You also need to readdress your understanding of array subscripts

this is my project
I want a running light which is controlled by the PIR sensor

No that's a link to TinkerCAD.

I don't have/want a TinkerCAD account.

Have you fixed the array indices?

"I want a running light which is controlled by the PIR sensor"

Do you have any specific requirements?

Hi,
You should be able to EXPORT a jpg image and post it into the forum.

Have you built the project, or just trying to run it on Tinker?

Tom... :grinning: :+1: :coffee: :australia:

I built it up
the problem was that the sensor did not recognize anything, so the led was not on.
I don't know if I have to read my sensor for the library.

Post code,not pictures.
Post error messages, not pictures

Your array has six elements (or it would, if you used commas instead of semicolons), so cannot possibly have elements with subscripts 6 and 7.

Hi,
To add code please click this link;

Thanks.. Tom.. :grinning: :+1: :coffee: :australia:

int pirPin = 8;
int ledPin [6] = {2;3;4;5;6;7};

     void setup ()   
       {
           pinMode(pirPin , INPUT);
           pinMode(ledPin 2, OUTPUT);
           pinMode(ledPin 3, OUTPUT);
           pinMode(ledPin 4, OUTPUT);
           pinMode(ledPin 5, OUTPUT);
           pinMode(ledPin 6, OUTPUT);
           pinMode(ledPin 7, OUTPUT);
          }

void loop() {
int s = digitalRead (pirPin);

     if (digitalRead(pirPin) == HIGH);

{ digitalWrite(ledPin[0], HIGH);
delay(500);
digitalWrite(ledPin0, LOW);
delay(500);
digitalWrite(ledPin1, HIGH);
delay(500);
digitalWrite(ledPin1, LOW);
delay(500);
digitalWrite(ledPin2, HIGH);
delay(500);
digitalWrite(ledPin2, LOW);
delay(500);
digitalWrite(ledPin3, HIGH);
delay(500);
digitalWrite(ledPin3, LOW);
delay(500);
digitalWrite(ledPin4, HIGH);
delay(500);
digitalWrite(ledPin4, LOW);
delay(500);
digitalWrite(ledPin5, HIGH);
delay(500);
digitalWrite(ledPin[5, LOW);
delay(500);
}
}

My Error Codes

exit status 1
expected '}' before ';' token

See reply #12

Please remember to use code tags when posting code

Hi,
Look through your code.
You should not have a ; immediately before a { , even if it is on the end of the line before.

Hint: Look at your if statements.

Tom... :grinning: :+1: :coffee: :australia:
PS. A mistake easily made.