Skip to main content

Datalogger Counter

  1. Navigate to HSYCO Manager

  2. Create a new project or open an existing one

  1. Go into the Home page

  1. Click "add"

  1. Add a "Datalogger"

  1. Go back to "edit" mode

  1. You can enlarge the object by dragging one of the corners

  1. Change the "Logger ID" to "logger1" (the counter logger we defined in the settings)

9. Change the "Controls" to "toolbar". This shows a toolbar to control live and browser modes

10. Change the "Value Label Type" to "popup". Value labels are now shown on mouseover or on touch

Tip: Now we'll add the button linked to the dummy light

  1. Click "add"

  1. Add a "Button"

  1. Click "edit"

  1. Align the button below the datalogger by clicking "Align" and then "Center Horizontally"

  1. Change the "Label" to "Dummy Light 1"

  1. Change the "Action" to "datapoint"

  1. Change the "Datapoint" to "dummy.light.1"

  1. Click "Save" to save the project

Tip: Great! Now we'll write some code to update the Datalogger when the button is pressed

  1. Go into "File Manager"

  1. Navigate into the "events" folder

  1. Click "New File"

  1. Give the file a name ("counterlogger.txt" for example) and click "New File"

**23. Copy the following code and save the file:

io dummy.light.1 = 1 : $loggercount + 1
$loggercount : DATALOGGER logger1 = $loggercount

What this does is, every time the "dummy.light.1" datapoint is on (or 1), it adds one to a local variable that counts the time this light has been light up. Then, when this variable changes, it updates the values of the Datalogger with ID "logger1" to the value of the local variable**

  1. Go back to the project and click "Run" and then "Default" to launch the application

  1. The page should look like this:

26. Press the button to light up the dummy light. As you can see, a bar has appeared in the graph and it shows that the light has been light up 1 time

27. If we press the button again, after turning off the light, a second bar shows up. If we head over the bar with the mouse, a popup value shows up and it shows the value of that bar. This because we previously set the "Value Label Type" to "popup"

  1. If we press the button twice in a short time (in this case in a minute because the datalogger has a resolution expressed in minutes as defines in the settings), the bar shows a value of 2 in the same bar