Shahariar
Published © CC BY-NC

Blinky Tune Badge

A badge to flash LED and play tone with adjustable tempo/blink rate.

BeginnerFull instructions provided4 hours1,923

Things used in this project

Hardware components

ATmega328
Microchip ATmega328
×1
Arduino UNO
Arduino UNO
×1
LilyPad LED Red (5pcs)
SparkFun LilyPad LED Red (5pcs)
×2
Resistor 330 ohm
Resistor 330 ohm
×8
SparkFun LiPo 40 mAh
×1
3x7 cm Protoboard
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

sch

Arduino Equiv

actual sch

Original

Code

main.c

Arduino
//  notes kiit 
//  F#4 G4 F#4  C#5  F#5 G5 F#5  C#5  F#4 G4 F#4 C#5  F#5 E5 (pause)
//  F#4 G4 F#4  C#5  F#5 G5 F#5  C#5  F#4 G4 F#4 C#5  F#5 G5  E5 F#5
//  http://pages.mtu.edu/~suits/notefreqs.html
#define note_Ch5 555
#define note_E5  660
#define note_Fh4 370
#define note_Fh5 740
#define note_G4  392
#define note_G5  784




int delay_val=10;
int tone_pin = 4;


void setup() {
  // initialize digital pin 13 as an output.
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  
   pinMode(2, INPUT_PULLUP);
   pinMode(3, INPUT_PULLUP); 
   attachInterrupt(0, dec_delay,FALLING);
   attachInterrupt(1, inc_delay,FALLING);
 
  
}

// the loop function runs over and over again forever
void loop()
{

//  F#4 G4 F#4  C#5  F#5 G5 F#5  C#5  F#4 G4 F#4 C#5  F#5 E5 (pause)
//  F#4 G4 F#4  C#5  F#5 G5 F#5  C#5  F#4 G4 F#4 C#5  F#5 G5  E5 F#5



kr_blink();  tone(tone_pin, note_Fh4, 150);
kr_blink();  tone(tone_pin, note_G4, 150);
kr_blink();  tone(tone_pin, note_Fh4, 150);
kr_blink();  tone(tone_pin, note_Ch5, 150);
kr_blink();  tone(tone_pin, note_Fh5, 150);
kr_blink();  tone(tone_pin, note_G5, 150);
kr_blink();  tone(tone_pin, note_Fh5, 150);
kr_blink();  tone(tone_pin, note_Ch5, 150);
kr_blink();  tone(tone_pin, note_Fh4, 150);
kr_blink();  tone(tone_pin, note_G4, 150);
kr_blink();  tone(tone_pin, note_Fh4, 150);
kr_blink();  tone(tone_pin, note_Ch5, 150);
kr_blink();  tone(tone_pin, note_Fh5, 150);
kr_blink();  tone(tone_pin, note_E5, 150);
delay(300);
kr_blink();  tone(tone_pin, note_Fh4, 150);
kr_blink();  tone(tone_pin, note_G4, 150);
kr_blink();  tone(tone_pin, note_Fh4, 150);
kr_blink();  tone(tone_pin, note_Ch5, 150);
kr_blink();  tone(tone_pin, note_Fh5, 150);
kr_blink();  tone(tone_pin, note_G5, 150);
kr_blink();  tone(tone_pin, note_Fh5, 150);
kr_blink();  tone(tone_pin, note_Ch5, 150);
kr_blink();  tone(tone_pin, note_Fh4, 150);
kr_blink();  tone(tone_pin, note_G4, 150);
kr_blink();  tone(tone_pin, note_Fh4, 150);
kr_blink();  tone(tone_pin, note_G5, 150);
kr_blink();  tone(tone_pin, note_E5, 150);
kr_blink();  tone(tone_pin, note_Fh5, 150);
 
 
}

void inc_delay()
{
  delay_val=delay_val+2;
}

void dec_delay()
{
  if(delay_val>3)
  delay_val=delay_val-2;
}

void kr_blink(void)
{
   digitalWrite(6, HIGH);   
  delay(delay_val);           
  digitalWrite(6, LOW);    
  delay(delay_val);             
  digitalWrite(7, HIGH);   
  delay(delay_val);           
  digitalWrite(7, LOW);    
  delay(delay_val);             
  digitalWrite(8, HIGH);   
  delay(delay_val);           
  digitalWrite(8, LOW);    
  delay(delay_val);             
  digitalWrite(5, HIGH);   
  delay(delay_val);           
  digitalWrite(5, LOW);    
  delay(delay_val);             
  digitalWrite(9, HIGH);   
  delay(delay_val);           
  digitalWrite(9, LOW);    
  delay(delay_val);             
  digitalWrite(10, HIGH);   
  delay(delay_val);           
  digitalWrite(10, LOW);    
  delay(delay_val);             
  digitalWrite(11, HIGH);   
  delay(delay_val);           
  digitalWrite(11, LOW);    
  delay(delay_val);             
  digitalWrite(12, HIGH);   
  delay(delay_val);           
  digitalWrite(12, LOW);    
  delay(delay_val);             
  digitalWrite(11, HIGH);   
  delay(delay_val);           
  digitalWrite(11, LOW);    
  delay(delay_val);             
  digitalWrite(10, HIGH);   
  delay(delay_val);           
  digitalWrite(10, LOW);    
  delay(delay_val);             
  digitalWrite(9, HIGH);   
  delay(delay_val);           
  digitalWrite(9, LOW);    
  delay(delay_val);             
  digitalWrite(5, HIGH);   
  delay(delay_val);           
  digitalWrite(5, LOW);    
  delay(delay_val);             
  digitalWrite(8, HIGH);   
  delay(delay_val);           
  digitalWrite(8, LOW);    
  delay(delay_val);             
  digitalWrite(7, HIGH);   
  delay(delay_val);           
  digitalWrite(7, LOW);    
  delay(delay_val);
}

Credits

Shahariar

Shahariar

74 projects • 265 followers
"What Kills a 'Great life' is a 'Good Life', which is Living a Life Inside While Loop"

Comments