Assignment #4: Discover Arduino

What I used

  • 6 LED and Tilt Sensor
  • Arduino
  • Manual Arduino StarterKit

I followed the project 8 of the starter manual of Arduino. In this tutorial is explained how to built a time tracker using a bunch of  led and a tilt sensor, a sensor that is like an Accelerometer, but less expensive and give less information (only up/down), in fact the Accelerometer is a tilt sensor it self.

The schema of the circuit that i followed was like this one:

arduino 08-01


How It works

Each Led switch on every 1000 millisecond and when the Tilt sensor is hit all the lad that was switch on switch of .


This is a snippet of the code :

void loop() {
unsigned long currentTime = millis();
 if(currentTime - prevTime > interval){
  prevTime = currentTime;
 switchState = digitalRead(switchPin);
 if(switchState != prevSwitchState ){
  for(int x=2; x<8;x++){
  led = 2;
  prevTime= currentTime;
 prevSwitchState = switchState;


Publié dans Uncategorized