Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Michail Marinis
Published © GPL3+

Newbie Music Player

A simple, yet somehow uncomplete music player from a newcomer.

BeginnerWork in progress30 minutes8,984
Newbie Music Player

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Generic 16x2 LCD
×1
Generic IR Receiver
×1
Resistor 221 ohm
Resistor 221 ohm
×2
Buzzer
Buzzer
×1
General Purpose Transistor NPN
General Purpose Transistor NPN
S8050
×1
Potentiometer
DIYables Potentiometer
×1
Jumper Wires
DIYables Jumper Wires
×23
Breadboard
DIYables Breadboard
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Mike_Player_Schematic

Code

Mike_Player

Arduino
The code for the project
#include <IRremote.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int speakerPin = 9;
int RECV_PIN = 13;
#define cL 129
#define cLS 139
#define dL 146
#define dLS 156
#define eL 163
#define fL 173
#define fLS 185
#define gL 194
#define gLS 207
#define aL 219
#define aLS 228
#define bL 232

#define c 261
#define cS 277
#define d 294
#define dS 311
#define e 329
#define f 349
#define fS 370
#define g 391
#define gS 415
#define a 440
#define aS 455
#define b 466

#define cH 523
#define cHS 554
#define dH 587
#define dHS 622
#define eH 659
#define fH 698
#define fHS 740
#define gH 784
#define gHS 830
#define aH 880
#define aHS 910
#define bH 933

IRrecv irrecv(RECV_PIN);
decode_results results;


void beep (int speakerPin, int freqHz, long timeMs)
{
  
  double timeDelay = (double)(1000000/freqHz);
  double timeLoop = (double)((timeMs*1000)/(timeDelay*2));
  
  for(int i = 0; i < timeLoop; i++)
  {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(timeDelay);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(timeDelay);
  }
  
  delay(20);
}


void Smoke()
{
  beep(speakerPin, cH, 500);
  beep(speakerPin, dHS, 500);
  beep(speakerPin, fH, 500);
  
  delay(250);
  
  beep(speakerPin, cH, 500);
  beep(speakerPin, dHS, 500);
  beep(speakerPin, fHS, 250);
  beep(speakerPin, fH, 550);
  
  delay(350);
  
  beep(speakerPin, cH, 500);
  beep(speakerPin, dHS, 500);
  beep(speakerPin, fH, 500);
  
  delay(250);
  
  beep(speakerPin, dHS, 500);
  beep(speakerPin, cH, 1500);
  
  delay(250);
}


void Jingle()
{
  beep(speakerPin, e, 300);
  beep(speakerPin, e, 300);
  beep(speakerPin, e, 500);
  
  delay(250);
  
  beep(speakerPin, e, 300);
  beep(speakerPin, e, 300);
  beep(speakerPin, e, 500);
  
  delay(350);
  
  beep(speakerPin, e, 350);
  beep(speakerPin, g, 350);
  beep(speakerPin, c, 350);    
  beep(speakerPin, d, 350);
  beep(speakerPin, e, 1000);
  
  delay(250);

  beep(speakerPin, f, 350);
  beep(speakerPin, f, 350);
  beep(speakerPin, f, 350);    
  beep(speakerPin, f, 300);
  beep(speakerPin, f, 300);
  beep(speakerPin, e, 320);
  beep(speakerPin, e, 320);
 

  beep(speakerPin, e, 150);
  beep(speakerPin, e, 150);
  beep(speakerPin, e, 150);
  beep(speakerPin, d, 340);
  beep(speakerPin, d, 340);
  beep(speakerPin, e, 440);
  beep(speakerPin, d, 540);
  beep(speakerPin, g, 440);

 delay(2000); 
}


void setup()
{
  lcd.begin(16,2);
  irrecv.enableIRIn();
  pinMode(speakerPin,OUTPUT);
  lcd.print("Mike Player");
  lcd.setCursor(0,1);
  lcd.print("Loading.");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.clear();
  lcd.print("Press Play");
}

void loop()
{
  if (irrecv.decode(&results))
  {
    lcd.clear();
    lcd.print("Select Song");
    lcd.setCursor(0,1);
    lcd.print("+:Song List");

    if (results.value==0xA3C8EDDB) //+
    {
      lcd.clear();
      lcd.setCursor(0,0);
      lcd.print("Smoke On The Water: 1   Jingle Bells: 2");
      for (int positionCounter = 0; positionCounter < 64; positionCounter++)
      {
        lcd.scrollDisplayLeft();
        delay(300);
      }

      
    }

    if (results.value == 0x9716BE3F) //1
    {
      Smoke();
    }

    if (results.value == 0x3D9AE3F7) //2
    {
      Jingle();
    }

    irrecv.resume();
  }
}

Credits

Michail Marinis
3 projects • 21 followers
Junior Software Engineer at ipQuants AG. Open to all critics, I'm trying to improve each and every day.
Contact
Thanks to AndruxMX.

Comments

Please log in or sign up to comment.