Case Study - Revolving Counter
This example will demonstrate the use of a variable to keep count of how many times a motion sensor was triggered. Once X number of triggers (iterations), the counting variable ‘count’ will reset back to 0. It also uses a variable ‘iterations’ to set the number of times to cycle before resetting count back to 0.
Required:
1 Motion Sensor
Before starting, set for expert mode: Settings->ExpertFeatures turn ON Expert Mode
Piston Mode: Basic
You will first create a local variable within the Piston called ‘count’ followed by a variable called ‘iterations’:
count = 0
iterations = 2 (or however many times you wish to cycle)
*Don’t forget when you are testing/playing with the code to reset the ‘count’ variable back to 0 if things get out of hand and you lose your way.