Digital Hourglass: Using millis() and tilt sensor to simulate a real hourglass!

     This project was based around sand hour glasses, in which they would fill up over time so you would know how much has passed, with the most common being an hour. These can be re-set by flipping them over, and therefore resetting the timer.

The parts included 6 red LED's, simulating the sand flowing with 6 intervals. Each Led was connected to a digital pin, where their values can be described as ON or OFF. They were connected to ground with a 220 ohm resistor. The tilt sensor determines when the Arduino is tilted (foolproof). The up direction means that the tilt sensor will not detect that tilting direction, so always tilt "away" from the tilt arrow direction.




        Setup set the LED pins as output (2 - 7) and the pin connected to the tilt sensor as input, to tell when to reset the LED's. The if statement checks to see if the time elapsed is longer than the interval, and if it is, it turns on the next LED in line (with the led++; line), and then resets the time for the next interval. The second if statement checks if the tilt sensor switch state is changed, and if it is it changes all the LED's at once back to their low setting.


    I found a weird glitch with the code where it left out a digit in the name for the Arduino, so it didn't register. It made me manually go into the terminal and change the Arduino name to the one it gave it. This was such a weird glitch because it is one I have never encountered before, and hopefully won't encounter it again.



This project was fun because it continued down the practical route from last week where we created a project that we can actually use in real life. I edited the interval time to be way shorter so you could see it in the GIF, but if you needed a 30 minute, 1 hour, or 3 hour timer, this would be a fun, less convinent way to do it.

Comments

Popular posts from this blog

Final Project: Reusing the Snake board design to create Tetris with the Arduino

Art Meets Engineering: Using an Arduino compatible microphone to create light based on sound