car belt warning please help

[code]
#include <SensorToButton.h>
#include <MusicWithoutDelay.h>
const char note1[] PROGMEM = {"::e2"};
MusicWithoutDelay pianoKey(note1);
#define BUTTON_PIN A0
#define Buton A0
#define Led 13
#define DEBOUNCE_MS 70
#define volt 7
SensorToButton firstKey(BUTTON_PIN, DEBOUNCE_MS);




void setup()
{
  pianoKey.begin(CHB, TRIANGLE, ENVELOPE0, 0);
  pianoKey.pause(true);   //bu kısmı değiştirdim false olarak
  pinMode(Buton, INPUT);
  pinMode(Led, OUTPUT);
  pinMode(volt, OUTPUT);
}

void loop()
{
  if (digitalRead(Buton) == 0)  //bu kısmıda değiştirdim
    digitalWrite(volt, HIGH);
  digitalWrite(Led, HIGH);


  if  (digitalRead(Buton) == 1)
    digitalWrite(Led, LOW);
  delay(500);
  digitalWrite(Led, LOW);
  delay(500);
  digitalWrite(volt, LOW);

  pianoKey.update();
  firstKey.read();
  buttonToPiano(firstKey, pianoKey);
  return; // bu kısmıda değiştirdim
}
void buttonToPiano(SensorToButton b, MusicWithoutDelay &m) {  //Must put & before object, because we must point to the address of the Object in the Arduino Memory
  if (b.isPressed()) {

    m.play(1);    //play one time


  }
}

[/code]

Hello guys, I'm preparing a seat belt warning project for my vehicle.
Now the code works fine, but I want to add a feature to it, I'm waiting for your help.

When the seat belt is not attached to the buckle, I want the warning to stop after about 2 minutes and to light on the lamp. In other words, I want the system to turn itself off automatically when no action is taken, the system needs to continue in the same way when the belt is attached.

So I want it to work like the existing system in vehicles now, I will do this because there is no warning system in my vehicle, thanks in advance for your help.

“ Hello guys, I'm preparing a seat belt warning project for my vehicle. Now the code works fine, but I want to add a feature to it, looking forward to your help.

I want the warning to stop and the lamp to come on after about 2 minutes, when the seat belt is not attached to the buckle. In other words, I want the system to shut down automatically when no action is taken, the system must continue in the same way when the belt is attached.

So now I want it to work like the current system on vehicles, I will do this because my vehicle has no warning system, thanks in advance for your help.”

google yranslete - next time save me the trouble!

a7

Thank you, I did not notice this situation :slight_smile:
automatic editing in dialing :slight_smile:

conk83:
When the seat belt is not attached to the buckle, I

How will the Arduino detect that?

If you can detect the connection (or lack of it) the rest will be straightforward.

...R

hm I guess in my car the beeping never stops. But to be really sure I have to test it let it beep for more than 2 minutes.

For safety-reasons a neverending beeping would be better.
Fasten seatbelt or stop driving.

best regards Stefan

Good question is I get this job with my Hall Efeckt sensor, so let's think like this, when there is no information from the sensor, a time cycle will perform the counting process.I want it to activate this system when there is no information from the sensor in a 2-minute period, but frankly, the system should work as it is when the information comes from the sensor.

The main situation is that I cannot run 2 different delay instructions in the system.

With which command should I do this command so that the system terminates itself when there is no information from the sensor?

Robin2:
How will the Arduino detect that?

If you can detect the connection (or lack of it) the rest will be straightforward.

...R

Can we do it as follows? I get information from the km sensor and throw it.When the speed exceeds 50 km, can we stop the warning and only want the seat belt light to remain constant.

You can have as much different timings as the RAM of the microcontroller can store them.

the function delay() is blocking. As long as the delay is executed nothing else of your code can be executed.

But there is a fundamental different technique of non-blocking timing.
This timing is called non-blocking.
As long as you try to see something similar like "delay" in the non-blocking timing it is hard to understand
because it is fundamentally different. As soon as you open your mind
"ok there comes something new" it will be easy to understand.

Some time ago user drmpf published a library that makes using non-blocking timing pretty easy
here is the tutorial with small and basic examples how it works

https://www.forward.com.au/pfod/ArduinoProgramming/TimingDelaysInArduino.html

best regards Stefan

StefanL38:
You can have as much different timings as the RAM of the microcontroller can store them.

the function delay() is blocking. As long as the delay is executed nothing else of your code can be executed.

But there is a fundamental different technique of non-blocking timing.
This timing is called non-blocking.
As long as you try to see something similar like "delay" in the non-blocking timing it is hard to understand
because it is fundamentally different. As soon as you open your mind
"ok there comes something new" it will be easy to understand.

Some time ago user drmpf published a library that makes using non-blocking timing pretty easy
here is the tutorial with small and basic examples how it works

https://www.forward.com.au/pfod/ArduinoProgramming/TimingDelaysInArduino.html

best regards Stefan

Thank you, I will examine

conk83:
Good question is I get this job with my Hall Efeckt sensor, so let's think like this, when there is no information from the sensor,

Presumably you also have a sensor to indicate there is a person sitting on the seat.

The timing should start from when the person sits on the seat and the alarm can be cancelled when the seat belt is fastened or when 2 minutes have elapsed.

...R

Robin2:
Presumably you also have a sensor to indicate there is a person sitting on the seat.

The timing should start from when the person sits on the seat and the alarm can be cancelled when the seat belt is fastened or when 2 minutes have elapsed.

...R

actually I have one sensor for the room seat belt buckle.
But I can add in the 2nd time, the room starts counting when the person is sitting on the lower part of the seat, yes, but at this time, we have a delay loop, we will wait for the previous situation in the 2nd delay counting operation, in this part counting will be on hold

conk83:
actually I have one sensor for the room seat belt buckle.
But I can add in the 2nd time, the room starts counting when the person is sitting on the lower part of the seat, yes, but at this time, we have a delay loop, we will wait for the previous situation in the 2nd delay counting operation, in this part counting will be on hold

I can't understand that. It looks as if translation has gone wrong. For example "room seat buckle" and "room starts counting"

And what do you mean by "add in the 2nd time" ?

You mention "delay loop". If that is using the delay() function then it is not appropriate. Have a look at how millis() is used to manage timing without blocking in Several Things at a Time.

And see Using millis() for timing. A beginners guide if you need more explanation.

...R

Robin2:
I can't understand that. It looks as if translation has gone wrong. For example "room seat buckle" and "room starts counting"

And what do you mean by "add in the 2nd time" ?

You mention "delay loop". If that is using the delay() function then it is not appropriate. Have a look at how millis() is used to manage timing without blocking in Several Things at a Time.

And see Using millis() for timing. A beginners guide if you need more explanation.

...R

Robin2:
I can't understand that. It looks as if translation has gone wrong. For example "room seat buckle" and "room starts counting"

And what do you mean by "add in the 2nd time" ?

You mention "delay loop". If that is using the delay() function then it is not appropriate. Have a look at how millis() is used to manage timing without blocking in Several Things at a Time.

And see Using millis() for timing. A beginners guide if you need more explanation.

...R

I do not have much English, so there may be problems in translation.

Now, when I do not wear the seat belt, the system is already working.

I can put another sensor on the seat within 2 minutes of delay, it starts the 2-minute time and it just cuts off the sound at the end of 2 minutes.

If this system does not exist, I think of cutting with another circuit from the outside.

Let's go back to the start. In your Original Post you said

Now the code works fine, but I want to add a feature to it, I'm waiting for your help.

When the seat belt is not attached to the buckle, I want the warning to stop after about 2 minutes

Tell us exactly what the working code does. Presumably you open the car door and get in and sit on the seat - what do you do next and what does the program do?

...R

Robin2:
Let's go back to the start. In your Original Post you said
Tell us exactly what the working code does. Presumably you open the car door and get in and sit on the seat - what do you do next and what does the program do?

...R

how the system works now
I have 1 sensor hall efect sensor when I put it on the seat belt buckle the flashing led turns off and the sound melody is cut off.
the system works actively when the buckle is not attached.
what do I want
When the belt is not fastened, a time cycle will begin. After 2 or 3 minutes, only stop the sound and the LED warning remains.
I can use another sensor to start this minute time to have the arduino detect it, but what changes should I make in the code to start this loop
So should I use a for loop?
Or should I use (militia)
Because there is a delay in the system, the software primarily sees the delay.

conk83:
how the system works now
I have 1 sensor hall efect sensor when I put it on the seat belt buckle the flashing led turns off and the sound melody is cut off.
the system works actively when the buckle is not attached.

You have forgotten to tell us what turns on the flashing and the melody. That's the important part as far as timing is concerned.

...R

Why for the love of everything holy would you want to add that to your car? How about a nice spike that stabs you in the rear when it goes off?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.