Skip to content

ATtiny project for a Birthday Pin with sound and light

License

Notifications You must be signed in to change notification settings

pixelEDI/attiny_birthdaypin

Repository files navigation

General info

Code

  • For this project we are working with the TimerFreeTone library, which allows us to play a note on a pin with a specific frequency in Hz for a desired duration in milliseconds.
  • The additional pitches.h defines the musical notes and associates them with their frequency so that you can address the notes by their names.
  • It is important that you flash your ATtiny25 with 8mHz, otherwise the sound will not play properly.
  • The ATtiny25 is big enough for a song with up to 28 notes. If you want to play a longer song, you have to take an ATtiny45.
  • First we create an array for the melody, consisting of the notes we want to play. For a pause in the music we define a NO_SOUND variable that has 0 Hz.
  • Next, we create an array for the duration. You have to enter a certain duration for each note, also for NO_SOUND.
  • The calculation of the musicLength was given, so just take it as it is.
  • In the loop, we let the LEDs flash alternately at the frequency of the notes and play the music.

Hardware

  • This little DIY pin runs on an ATtiny25.
  • For the sound we added a piezo buzzer and a 100 Ω resistor to make the sound softer
  • There are also three 3mm LEDs connected with a 100 Ω resistor as well.
  • We power the pin with a CR2032 3V button cell battery

Verdrahtung

3D Case

Get the Case: Thingiverse

You like it? Then I would be very happy if you treat me to a coffee on ko-fi.com/pixeledi

Releases

No releases published

Packages

No packages published