I am pondering on how to make a internet meter. A meter that should show the activity on my WAN port on my router.
My plan is to first observe how fast it can flash. So see how long between flashes there are, I made this little code
int sensorPin = 5; // select the input pin for the sensor
int sensorValue = 0; // variable to store the value coming from the sensor
unsigned long ping;
boolean isSet = false;
sensorValue = analogRead(sensorPin);
unsigned long output;
if (sensorValue < 800)
isSet = true;
output = millis()-ping;
ping = millis();
Serial.print((double)(output/1000.0)); Serial.println(" sec");
if (sensorValue > 800)
isSet = false;
This will show in seconds (with two decimals) how long there are between the LED flashing. If more accuracy needed, I can just remove the /1000.0 where it is printed by serial.
Output after testing on the hdd led on my computer for a few seconds.