Go Down

Topic: Arduino with magnetic sensor...Help please.! (Read 2702 times) previous topic - next topic

Zinonas

I use an arduino uno with a magnetic sensor because i want to create a parking spaces availability.! I have already finish the code to detect the change of the sensor values when a car park over the sensor.. And now i want to write a code to find the time of this change.. What is the easiest method.?? I am thinking to send the data into an array and compare the values so i can find the change between the values.. I am not sure how can i do it.. If anyone can help me with his advice or with example of code please reply..!! Thank you.!

In this picture are the values that i take from the sensor.. the grad value change when i have magnetic field over the sensor.. As you can see grad=149.08, grad= 147.65, grad= 148.53, grad= 149.08 and after that i place magnetic field go to grad= -15.11, grad= -130.60, grad= -129.89, grad= -130.60, grad= -129.89. This is the change that i want to detect and for example after that i will turn on the led.!

johnwasser


now i want to write a code to find the time of this change.. What is the easiest method.??


There is a Time library that can help:  http://playground.arduino.cc/Code/Time

You will probably want to add a Real Time Clock since the Arduino is not great at keeping time by itself.

http://playground.arduino.cc/Main/DS1302
http://www.ladyada.net/learn/breakoutplus/ds1307rtc.html
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

PaulS

You can use millis() to determine, relative to when the Arduino started, when the value changed to "car parked here" or when it changed to "no car parked here". The difference is how long the car was parked there, in milliseconds. Converting that to seconds, minutes, hours, days, etc. is simple math.

Zinonas

Thank you very much for help..!! It was very important for me.! Thank you again.!

Go Up