Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering

Arduino Based Music Notes and Melody Generator with LCD

By Ashutosh Bhatt

Arduino has a wide variety of applications. It can find its use in almost all fields. Its applications increase day by day because it’s open source and anyone can create a new set of functions and library to interface any new device with Arduino. The given application demonstrates the use of Arduino as tone and melody generator. It includes keypad and LCD for user interface. The music notes or melody is generated when the key is pressed and the frequency of generated sound is displayed on LCD. So actually the given application illustrates keypad and LCD interfacing with Arduino along with tone – melody generation.
Prototype of Arduino Based Music Notes and Melody Generator

Fig. 1: Prototype of Arduino Based Music Notes and Melody Generator

Circuit description:

As shown in circuit one 16×2 LCD, one 4×3 matrix keypad, and one 8Ω speaker is interfaced with arduino board.
• The Vcc pin (2) and Vss pin (1) of LCD are connected to +5 V and Gnd pins of arduino board respectively to provide it biasing.
• LED+ pin (15) and LED- pin (16) of LCD are also connected to +5 and Gnd pins respectively to turn ON LED backlight of LCD.
• Rs pin (4) and En pin (6) are connected with arduino digital pins 8 and 9 while Rw pin (5) is permanently connected to ground for write enable.
• Data pins D4 – D7 of LCD are connected with arduino digital pins 10 – 13
• 3 columns C1, C2, and C3 of matrix keypad are connected with 0,1 and 2 pins of arduino board while 4 rows R1, R2, R3, and R4 are connected with 3, 4, 5 and 6 pins.
• One 8Ω speaker is connected to pin 7 as shown in the circuit diagram.

Circuit operation:

• Initially, the message is displayed on LCD as “keypad tone generator”
• When any key is pressed, the key press is detected and arduino identifies which key is pressed
• Based on key number that is pressed, the particular frequency sound* (tone) is generated through speaker for 1 sec time
• The key number is displayed on LCD also the frequency of generated sound is displayed on LCD
• As shown in the figure the keypad is phone keypad (numeric) it includes * key and the # key. So when * key is pressed then it generates tone melody 1 and when # key is pressed it generates tone melody 2 that is displayed on LCD
*Note: the frequency of generated sound is chosen as to produce ‘sa’, ‘re’, ‘ga’, ‘ma’, ‘pa’, ‘dha’ and ‘ni’ all seven notes of music
The complete functionality of this project is due to the software program loaded into internal FLASH memory of arduino board microcontroller ATMega328. So let us see the program and its logic explanation.

Software program and logic:

The software program is written in arduino language. It is compiled using arduino IDE software tool and uploaded into internal FLASH memory of arduino board microcontroller. We all know arduino IDE has powerful library package that includes a complete set of functions for the particular peripheral device. In this program, we are using three libraries:
1) matrix keypad – to interface matrix keypad with arduino
2) liquid crystal  – to interface LCD with arduino
3) tone generator – to generate different frequency sound
The matrix keypad library allows us to configure our matrix keypad as a number of rows-columns, key pattern etc everything. It detects key press, identifies which key is pressed and does many other functions. Liquid crystal library is as we know especially to interface different types of LCDs with arduino. It configures LCD, displays text, numeric data, clears LCD, sets cursor positions, etc. Tone generator is used to generate particular frequency sound from any digital pin of arduino.

Project Source Code

###

//Program to 

#include 

#include 


const byte ROWS = 4; // Four rows

const byte COLS = 3; // Three columns

int sound[10] = {1047,1109,1245,1319,1397,1480,1568,1661,1760,1865};

int sound_pin = 7;

// Define the Keymap

char keys[ROWS][COLS] = {

  {'1','2','3'},

  {'4','5','6'},

  {'7','8','9'},

  {'#','0','*'}

};

// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.

byte rowPins[ROWS] = { 3, 4, 5, 6 };

// Connect keypad COL0, COL1 and COL2 to these Arduino pins.

byte colPins[COLS] = { 0, 1, 2 }; 


// Create the Keypad

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

LiquidCrystal lcd(8, 9, 10, 11, 12, 13);

#define ledpin 13

void setup()

{

  pinMode(ledpin,OUTPUT);

  digitalWrite(ledpin, HIGH);

  lcd.begin(16, 2);

  lcd.clear();

  lcd.print("   keypad tone");

  lcd.setCursor(4,1);

  lcd.print("generator");

}

void loop()

{

   int i;

   char key = kpd.getKey();

   if(key)  // Check for a valid key.

  {

    switch (key)

    {

      case '*':

        lcd.clear();

        lcd.print("playing melody 1");

        for(i=0;i<10;i++)

          tone(sound_pin,sound[i],500);

        break;

      case '#':

        lcd.clear();

        lcd.print("playing melody 2");

        for(i=0;i<10;i++)

          tone(sound_pin,sound[10-i],500);

        break;

      default:        

        lcd.clear();

        lcd.print("key:");

        lcd.print(key);

        lcd.setCursor(0,1);

        lcd.print("sound ");

        lcd.print(sound[key-48]);

        lcd.print(" Hz");

        tone(sound_pin,sound[key-48],1000); 

        break;

    } 

  }     

} 

###

 


Circuit Diagrams

Circuit-Diagram-Arduino-Based-Music-Notes-Melody-Generator

Project Video


Filed Under: Arduino, Electronic Projects

 

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • PS2 Keyboard To Store Text In SD Card Using Arduino Circuit Setup On Breadboard
    How To Use PS2 Keyboard To Store Text In SD Card Using Arduino- (Part 42/49)
  • Wireless Path Tracking System Using Mouse, XBee And Arduino Circuit Setup On Breadboard
    How To Make A Wireless Path Tracking System Using Mouse, XBee And Arduino- (Part 43/49)
  • How to Make a Wireless Keyboard Using Xbee with Arduino- (Part 44/49)
  • Making Phone Call From GSM Module Using Arduino Circuit Setup On Breadboard
    How to Make Phonecall From GSM Module Using Arduino- (Part 45/49)
  • How to Make a Call using Keyboard, GSM Module and Arduino
    How To Make A Call Using Keyboard, GSM Module And Arduino- (Part 46/49)
  • Receiving SMS Using GSM Module With Arduino Prototype
    How to Receive SMS Using GSM Module with Arduino- (Part 47/49)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • Renesas delivers intelligent sensor solutions for IoT applications
  • Microchip Technology releases AVR-IoT Cellular Mini Development Board
  • Qualcomm acquires Cellwize to accelerate 5G adoption and spur infrastructure innovation
  • MediaTek’s chipset offers high-performance option for 5G smartphones
  • Nexperia’s new level translators support legacy and future mobile SIM cards

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr bluetooth dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • about ATmega328 ADC pins
  • Tuning the antenna to be conjugately matched to input impedance of the die
  • Netlist physical name update
  • nt1065_USB3 gnss receiver
  • LLC HB with synchronous rectifiers can be very dodgy?

RSS Electro-Tech-Online.com Discussions

  • undefined reference header file in proteus
  • Capacitor to eliminate speaker hum
  • Decapped Chip On Board
  • Sony KV-A2913E (chassis AE1C) auto shuts off after one minute
  • CRT TV repair
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
    • Design Guides
      • WiFi & the IOT Design Guide
      • Microcontrollers Design Guide
      • State of the Art Inductors Design Guide
  • Women in Engineering