Notifications
Clear all

fresh eyes and a little help

52 Posts
4 Users
2 Reactions
1,955 Views
(@usagi_13hotmail-com)
Supreme Сasual Dating - True Females
Joined: 2 years ago
Posts: 31
Topic starter  

Briefing I'm trying to make a sketch using arduino nano, dfplayer, neopixels and pir sensor the wiring is standard rx and tx to 10,11 pir pin 2 neopixels 5

object is to have the pixels come on when the dfplayer is triggered by the pir sensor and turn off after the mp3 player has finished playing.

what I have achieved as a beginner is what some of the pros would call a Frankenstein sketch comprising bits of other sketches and my lack and ability to write my own code I'm code semi illiterate. However that being said I have been at this for days not only trying to get it working but reading and trying other sketches and parts to the point I just have to now ask for a little help.

my sketch is partly working I can get the dfplayer to play I can get the lights to turn on the dfplayer starts as soon as it powered and after it's played you can trigger it with the pir however the lights come on but stay on i have attached the sketch if anyone can help it would be greatly appreciated.

 

This topic was modified 1 year ago by usagi_13@hotmail.com

[URL=https://datesnow.life]Verified Maidens[/URL]


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7334
 

Posted by: @usagi_13hotmail-com

Briefing I'm trying to make a sketch using arduino nano, dfplayer, neopixels and pir sensor the wiring is standard rx and tx to 10,11 pir pin 2 neopixels 5

object is to have the pixels come on when the dfplayer is triggered by the pir sensor and turn off after the mp3 player has finished playing.

what I have achieved as a beginner is what some of the pros would call a Frankenstein sketch comprising bits of other sketches and my lack and ability to write my own code I'm code semi illiterate. However that being said I have been at this for days not only trying to get it working but reading and trying other sketches and parts to the point I just have to now ask for a little help.

my sketch is partly working I can get the dfplayer to play I can get the lights to turn on the dfplayer starts as soon as it powered and after it's played you can trigger it with the pir however the lights come on but stay on i have attached the sketch if anyone can help it would be greatly appreciated.

-- attachment is not available --

 

 

I only took a quick look at your code and I see where the comment says to turn the lights off, but it has been commented out. Maybe enable that code?

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2548
 

@ozyjimbo

I can't replicate your project because I don't have the modules to do so.

However, I will point out that there are 4 cases possible and you're only addressing two of them. The 4 cases are:

1 - (digitalRead(PIR) && !PIR_STATE)

2 - (digitalRead(PIR) && PIR_STATE)

3 - (!digitalRead(PIR) && PIR_STATE)

4 - (!digitalRead(PIR) && !PIR_STATE)

Your code only handles cases (1) and (3). It appears that you only want to play the sound in case 1 so you may want to change the

else if(!digitalRead(PIR) && PIR_STATE)) {
 
to
  else {
    PIR_STATE = false;  //Reset PIR module state

    if (Millis - Millis_previous > 90000) {
      movement_detected = false;  //Reset movement_detected variable
      pixels.clear();
    }
  }

 This clears the PIR_STATE flag and, after 90 seconds, should clear the movement detected and turns off the lens.

 

 

Anything seems possible when you don't know what you're talking about.


   
ron bentley reacted
ReplyQuote
(@usagi_13hotmail-com)
Supreme Сasual Dating - True Females
Joined: 2 years ago
Posts: 31
Topic starter  

@zander nahh it still doesn't work with it being included thats why i commented it out in both cases

[URL=https://datesnow.life]Verified Maidens[/URL]


   
ReplyQuote
(@usagi_13hotmail-com)
Supreme Сasual Dating - True Females
Joined: 2 years ago
Posts: 31
Topic starter  

@will ahhh i will give that a try as i always thought the clear pixels was to be included in the main loop but having seen so many sketches i had forgot that comment

[URL=https://datesnow.life]Verified Maidens[/URL]


   
ReplyQuote
(@usagi_13hotmail-com)
Supreme Сasual Dating - True Females
Joined: 2 years ago
Posts: 31
Topic starter  

@will no joy no matter what i did including pixels.clear didn't work 😒

[URL=https://datesnow.life]Verified Maidens[/URL]


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2548
 

@ozyjimbo 

Did you change the logic to cover the two missing cases as well ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@usagi_13hotmail-com)
Supreme Сasual Dating - True Females
Joined: 2 years ago
Posts: 31
Topic starter  

@will ermmm to be honest no i didn't i only saw the pixels clear and didn't do the others will try your other suggestions after my eyes stop bleeding lol

[URL=https://datesnow.life]Verified Maidens[/URL]


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2548
 

@ozyjimbo 

I think your problem is that once the PIR triggers you keep looping and neither of your two cases occur, after that so the lights never shut off. The critical part of my post was that you need to handle the two other cases, not using clear() to turn off the leds.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@usagi_13hotmail-com)
Supreme Сasual Dating - True Females
Joined: 2 years ago
Posts: 31
Topic starter  

@will made the changes it's funny how you can go text blind but still no joy lights are still staying on after making those changes to the pri && pir state comments

[URL=https://datesnow.life]Verified Maidens[/URL]


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2548
 

@ozyjimbo 

OK, let me try to guess what you're looking for. here's a simplified version, tell me if this gets you any closer to what you want.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@usagi_13hotmail-com)
Supreme Сasual Dating - True Females
Joined: 2 years ago
Posts: 31
Topic starter  

@will sorry it's taking long to reply i will try you ino trhe reason is the mp3 is about 3 to 4 mins long then i have to wait till it finishes to see if the results are fruitful then i make more changes and have to go through it all again

[URL=https://datesnow.life]Verified Maidens[/URL]


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2548
 

@ozyjimbo 

No rush, I'm old and have nothing to do and all day to do it in. What I don't finish today I'll do tomorrow.

If you want to speed up the cycle, use a shorter MP3.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
(@usagi_13hotmail-com)
Supreme Сasual Dating - True Females
Joined: 2 years ago
Posts: 31
Topic starter  

@will have tested your ino but problem it doesn't turn on the mp3 it just keeps flashing and when I reset on the nano it starts playing but since no power it stops so i edited it to have the mp3.play on top of the loop before the pixels but same result

[URL=https://datesnow.life]Verified Maidens[/URL]


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2548
 

@ozyjimbo 

I'm sorry, I don't have the player so I can't analyze what's wrong. I just copied the line which appears to start the player from your original code.

When you say the leds keep "flashing", do you mean like they blink continuously or do they flash on for 90 seconds and then off ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Page 1 / 4