Pages: [1]   Go Down
Author Topic: Arduino with magnetic sensor...Help please.!  (Read 2560 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.!


* magnetic.jpg (93.99 KB, 309x734 - viewed 36 times.)
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 642
Posts: 50366
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: