Giter Site home page Giter Site logo

musical-embedded-system's Introduction

APS-Musical

A embedded system that can play monophonic music. Here`s a link to a video that demonstrates the project working.

Table of contents:

Components

Connections

Set-up/Running the project

Code Structure

References/Credits

Components

Here are all components used in this project:

  • Atmel SAM E70 XPLAINED (link)
  • OLED1XPLAINEDpro (link)
  • 1x BUZZER
  • 2x JUMPERS (female-to-female or male-to-female)
  • 1x PROTOBOARD (only necessary when jumpers are male-to-female)

Connections

The connection needs to be as the following: alt text

Set-up/Running the project

After connecting the components, the cable must be plugged in the computer USB. To compile the program, the software used is Atmel Studio 7.0, so it needs to be opened in order to run the project.

The buttons, led, buzzer and screen works as the following:

Type Action Connection
Button 1 Previous music PIOD28
Button 2 Play / Pause PIOC31
Button 3 Next Music PIA19
Led 1 Lower frequencies PA0
Led 2 Mid frequencies PIOC30
Led 3 Higher frequencies PIOB2
Buzzer Play frequency PIOA3 / GND
Screen Displays music name ---------------

Code Structure

The code structure is expalined below:

๐Ÿ“ screen/

// Files used by OLED display.

๐Ÿ“ include_files/pios.h

// Header file that define all OLED buttons, led and the buzzer PIO`s.

๐Ÿ“ include_files/structures.h

// Header file that define the music struct.
typedef  struct {
...
} Song_to_play;

๐Ÿ“ include_files/musics.h

(all credits)

// Header file that define the musics frequencies and tempo`s.
int mario_main[]
int mario_main_tempo[]
int pirates_of_the_caribean[]
int pirates_of_the_caribean_tempo[]
int underworld_mario[]
int underworld_mario_tempo[]

๐Ÿ“ include_files/frequencies.h

// Header file that define all frequencies.

๐Ÿ“ include_files/init_functions.h

// Header file that define all initial configurations.
void create_songs() { ... } // Create all songs and transform them into structures for function passing
void init(void) { ... } // Clock init, create interruptions, set pio output and input
// Callbacks functions for interruption
void but_next_callback(void){ ... }
void but_prev_callback(void){ ... }
void but_play_callback(void){ ... } 

๐Ÿ“ include_files/core_functions.h

// Header file that define all core and functional functions.
void pause() { ... } // Pause music
void oled_draw(char*  string, int  size) { ... } // Function that display the given string to oled with text centralization
void buzz(int  frequency, int  length, int  max, int  min) { ... } // Make the buzzer play the song frequency and control the LED`s.
void play(Song_to_play  song) { ... } // Play the given song, call buzz() whenever a note needs to be played and pause() whenever the pause button is pressed

๐Ÿ“ƒ asf.h

// Header file that includes all API header files for the selected drivers from ASF.

๐Ÿ“ƒ aps.h

// Header file that includes all include_files/ and screen/ header file.
#include  "include_files/*.h" 

๐Ÿ“‘ main.c

// c file that control wich core_functions are called, skip, play and return to previous music. Uses the init_functions to create songs and init pio clock
int main(void) {
	init();
	create_songs();
	
	while (1) { ... } // Play, pause, draw, ...
}

References/Credits

๐ŸŽต Super Mario Main Theme

by Prince @ princetronics.com

๐ŸŽต Pirates of The Caribbean

by Xitang 2016.06.27 @ github

๐ŸŽต Underworld Mario

by Prince @ princetronics.com

๐Ÿ“ƒ Code adapted from:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.