Need Help With School Project (Absolute Beginner)

Hi there!

I Have to make a metronome with arduino for school using a Switch, Potmeter, Piezo speaker and a Neopixel diffused. The neopixel has to fade into a different colour on every beat and the bps has to be able to change with the use of a potmeter. (The colour fades has to happen as smooth as possible)

My achievments:
-The potmeter changes the pitch of the speaker
-The switch puts the speaker on and off

The problems that needs to be solved:

  • Speaker doesn't bleep but makes a constant pitch tone.
  • Neopixel doesn't react to the switch when pressed on or off.
  • The neopixel doesn't react to the sound/bps with fading colours.

I've provided the code I've been working with as an attachment.

Neopixel.ino (1.98 KB)

You're telling the piezo to beep in loop() but loop() may run quicker than your beep duration so that the beep is restarted before it finishes. Try using micros() to control the beep duration and also the non-beep (silence) duration.
Each time through your loop, check: if beep is on, is it time to turn it off? If beep is off, is it time to turn it on?

Aah thank for the tip, Ive got the bleeping working now. Although, the potmeter regulates the volume of the bleeping instead of the BPS. I cant seem to get my project complete yet.

In the youtube link you can find a similar project, the only difference is:

I have to use an Neopixel to react to the BPS with an colorfading effect instead of just two LEDS going on and off the whole time with the BPS.

Neopixel_1.ino (2.09 KB)

FYI, there is no such thing as a "potmeter". It's called a "potentiometer" or "pot" for short.

raschemmel:
FYI, there is no such thing as a "potmeter". It's called a "potentiometer" or "pot" for short.

There may well be such a thing as a potmeter, but it would be used to measure illegal drugs :wink:

Maybe it was Freudian slip....

Lol, allright guys I get the point about the Pot/Potentiometer...