// (Worksheet 4-9-1s - Timing ) // (Worksheet 4-9-1s Number 4) // It is likely that your code took longer to draw than you expected. // Modify your system so that it will display a picture in less than 0.25 seconds. // Consider changing the stepsize in the loop that controls when each LED is on or off. // (Worksheet 4-9-1s Number 5) // To display the image in the same place each time we need to have a reference point in the rotation. // We will use a Hall-effect sensor that toggles between HIGH and LOW each time the handle turns. // First wait for the sensor to be HIGH, then wait for the sensor to go LOW again. // The sensor is connected to an analog pin which has a range from 0 to 1023 (10 bits). // By setting a HIGH threshold of 600 and a LOW threshold of 400 we avoid false triggers as the input slowly moves through the LOW to HIGH transition. This is called hysteresis. // Create a function called void waitForTrigger() that reads the analog I/O pin connected to the Hall-effect sensor. // Functions should be created outside of any other function definitions. // Use analogRead() to get the input value. You should have defined a reference to the pin earlier // Use a first while () loop to wait until the pin is high (value > 600). // Then use a second while() loop to wait until it goes low (<400). void waitForTrigger(void) { while (analogRead(magneticSensor) < 600) { // stay here as long as the pin value is less LOW (less than 600). } while ( ) {// you finish this one. } } // (Worksheet 4-9-1s Number 6) // Call the waitForTrigger() function at the beginning of your main loop() function.