diff --git a/examples/flow_sensor/main.go b/examples/flow_sensor/main.go index f8658a7..89f01c0 100644 --- a/examples/flow_sensor/main.go +++ b/examples/flow_sensor/main.go @@ -31,7 +31,8 @@ func main() { defer line.Close() defer lfs.CloseChannels() - // listen the measurement if you want to take action or print the values. Do whatever you want. + // Listen the measurement if you want to take action or print the values. Do whatever you want. + // Here shutdown when 100 liters are measured for { printMeasurement(<-lfs.Subscribe()) if lfs.GetMeasurement() > 100 { diff --git a/examples/photocell_sensor/main.go b/examples/photocell_sensor/main.go index ac461a3..2a535a3 100644 --- a/examples/photocell_sensor/main.go +++ b/examples/photocell_sensor/main.go @@ -32,16 +32,14 @@ func main() { defer line.Close() defer pcs.CloseChannels() - // listen the measurement if you want to take action or print the values. Do whatever you want. - for { - printMeasurement(<-pcs.Subscribe()) - if pcs.GetMeasurement() > 100 { - break - } + // Listen the measurement if you want to take action or print the values. Do whatever you want. + // Here shutdown after measuring 1000 times + for i := 0; i < 1000; i++ { + printMeasurement(i, <-pcs.Subscribe()) } } -func printMeasurement(measurement int) { - log.Printf("Brightness is: %d", measurement) +func printMeasurement(noOfMeasurement int, measurement int) { + log.Printf("Measurement %d, Brightness is: %d", noOfMeasurement, measurement) }