I have a sensor that return their info with a led flashing ( the temp for example is measured depending of the number of blinks of the led)
more temp = faster flashes (Blinks) of the led
less temp = less flashes
usually the range I use is aprox from 10 to 50 flashes per second ( I dont count every flash is aprox, but is always blinking, i never see the led like a continue ON led)
My question is, how can I translate that info for the arduino.
Im a newbie and maybe is a dedicated code or pin for that but i dont know, I only use analogic and digital, and I think analog dont work because the loops of the arduinos sometimes will catch the led on or off but wont recognize the time between flashes, and digital i think neither)
Is a "handmade" sensor haha, of course are more easy ways, but It is a sensor we already build for a previous stage of the project, when we needed to do it that way, now we need to integrate the sensor exactly as it is. School stuff....
But if there is no way, I will use a diferential voltage that move the frecuency of the flashes connected just to an analog input haha
There is a way, it's easy and the guys have mentioned it twice, interrupts.
In fact there's probably a 100 ways to do it, but here's one take.
You set an interrupt to trigger say on the rising edge of your LED, the interrupt service routine (ISR) records the fact that the event has happened by setting a global variable to the millis() value. Your loop() code tests the variable and compares it with the saved value from last time there was a pulse. If they are different a new pulse has occured so you subtract the new value from the old value to get the duration of the pulse and overwrite the old value with the new value.
At 50 pulses per second this would work but have pretty course resolution. How accurate do you need to be?