简体   繁体   中英

Android light sensor : detect specified flash code

i wanna know how to recognize flash code of the blinking LED. If I set in app correct code: 0,5+1;0,5+3 (0,5 sec LIGHT , 1 sec DARK, 0,5 sec LIGHT, 3 sec DARK),and then with light sensor detect LED flashing, how to recognize first flash (0,5) if flashing is continuously?? How to compare detected values with specified?

Considering you are getting the signal without noise, then you will be getting a sequence: 0.5 LIGHT , 1 DARK, 0.5 LIGHT, 3 DARK, 0.5 LIGHT , 1 DARK, 0.5 LIGHT, 3 DARK, ...

In this way, I think you are not matching a specific event, but matching using a time window (0.5 + 1 + 0.5 + 3 = 5 seconds). When moving the time window along the signals detected, you will find your events, and then you can identify the specific ones.

It's important to check the frequency you can get out of the light sensor. Let's say, if you are getting at 10fps, then you will get an array of values:

[0, 10, 200, 230, 209, 198, 201 , 10, 7, 20, 17, 18, 10, 11, 10, 12, 13, ... ]

Then, by setting a threshold, you can see where is the start and end of light and dark.

When you are using the time window of 5 seconds, the array you keep will be at a length of 50. You might want to check the array by first connecting the head and tail of it in order to match the sequence you want.

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM