Digital Hourglass

Hello everyone, i was building the Arduino Digital Hourglass. But it doesn't work. I don't know what i did wrong. I put a picture below.

If you can't see the picture: https://goo.gl/photos/VS5i5qnofA7xUr6t6 Kind regards, Sander

Hi.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Does it do anything at all?

You can attach files to REPLY if you like.
But we need your code, are the diodes the right way round.

Tom… :slight_smile:

it doesn't work

We hate that phrase, because it means so many things.

the Arduino Digital Hourglass

And what is that?

Do you have a link to it?

Code for it?

Sander_A: Hello everyone, i was building the Arduino Digital Hourglass. But it doesn't work. I don't know what i did wrong. I put a picture below.

And if you got a problem with your car, you take a picture of your car, send the picture to a car repair shop along with the message "It doesn't work."

Then the garage owner will take a look on the picture of your car and tell you what's wrong with your car, right?

Hi, Here is my code:

void setup() {

  for (int x = 2; x < 8; x++) {
    pinMode(x, OUTPUT);
  }
  // set the tilt switch pin as input
  pinMode(switchPin, INPUT);
}

void loop() {
  
  unsigned long currentTime = millis();

  
  if (currentTime - previousTime > interval) {
    
    previousTime = currentTime;
   
    digitalWrite(led, HIGH);
  
    led++;

    if (led == 7) {
  
    }
  }


  switchState = digitalRead(switchPin);

 
  if (switchState != prevSwitchState) {
   
    for (int x = 2; x < 8; x++) {
      digitalWrite(x, LOW);
    }

   
    led = 2;

    
    previousTime = currentTime;
  }

  prevSwitchState = switchState;

}


If you can’t see: https://goo.gl/photos/nH9X7SyeBNaPRy7x6

This is what is the Digital Hourglass:

Just a project from the starter kit.

And the LED’s won’t light up .

Sander

if (led == 7) {
 
   }

this is a nice short if statement.

alas, I an not an expert (or good) coder, so am not sure what it does.

what happens when you write each pin low, then high and use a simple delay of 100 ?

Sander_A:
Hi, Here is my code:

That is not a complete program.

Help us to help you by posting a complete program.

Can you get any LED to light ?
It is possible the LEDs are inserted the wrong way round ?
As was requested in Reply #1, please provide a diagram showing how YOU have everything connected. A photo of a pencil drawing would probably be best.

…R

https://goo.gl/photos/Yd44stJK7da1YSr1A

That is how I connected it.

Sander_A:
And the LED’s won’t light up .

Is your switch working?
Switch pin with PullDown resistor in your circuit?

When developing sketches, you ALWAYS should try to use “serial debug messages” that might show you what’s going on in your code.

Here is your code with some serial debugging added:

void setup() {
  for (int x = 2; x < 8; x++) {
    pinMode(x, OUTPUT);
  }
  // set the tilt switch pin as input
  pinMode(switchPin, INPUT);
  Serial.begin(9600);
  Serial.println("Good night and good luck!");
}

void loop() {
  
  unsigned long currentTime = millis();

  
  if (currentTime - previousTime > interval) {
    
    previousTime = currentTime;
   
    digitalWrite(led, HIGH);
  
    led++;

    if (led == 7) {
  
    }
  }


  switchState = digitalRead(switchPin);

 
  if (switchState != prevSwitchState) {
    Serial.print("Switch state changed to: ") 
    Serial.println(switchState);
    for (int x = 2; x < 8; x++) {
      digitalWrite(x, LOW);
    }

   
    led = 2;

    
    previousTime = currentTime;
  }

  prevSwitchState = switchState;
}

After uploading the sketch, open the “Serial monitor”.
You should then see the greeting message “Good night and good luck!”.
If you don’t see that message, check the baud rate setting in the serial monitor!

An then watch what happens when pressing and releasing the switch.
Do you see any "Switch state changed to: " messages?
Do they appear as expected?

Hello all,

Thank you for all help. And sorry for being newbie. The problem is fixed ;-)

Thanks again

Greetings,

Sander!

It was just a sensor that doesn’t fit so well in the breadboard…