Project tutorial
Control Music Volume and Ledbar Using Slider of 1Sheeld

Control Music Volume and Ledbar Using Slider of 1Sheeld

Do you want to visualize the music volume on a led bar. We will make it easy as breathing specially when using the amazing 1Sheeld.

  • 1,900 views
  • 2 comments
  • 14 respects

Components and supplies

Apps and online services

About this project

The project is about how to control the music volume and visualize the volume level on a led bar in an easy way by using the amazing 1Sheeld.

1Sheeld turns your smart phone into more than 40 different Arduino shields so it's saves a lot of money and gives you the ability to make great projects and it's available at both android studio and apple store.

You can check all 1Sheeld's tutorials which will take you from the early beginning into more and more advanced projects from that link. http://1sheeld.com/tutorials/

And you can order it from here

All the details of how it works will be in the video uploaded and you can find the hardware connections in the schematic.

Code

control music volume and led bar by usning 1sheeld sliderArduino
/*
 * @title    : Controlling music volume and led bar using the amazing 1sheeld
 * @author   : Ahmed Ismail
 * @email    : ahmed.ismail3115@gmail.com
 * @compiler : Arduino IDE
 */





#define CUSTOM_SETTINGS
#define INCLUDE_SLIDER_SHIELD
#define INCLUDE_MUSIC_PLAYER_SHIELD
/* Include 1Sheeld library. */

#include <OneSheeld.h>

byte value; /* define a variable to hold the slider values. */

int led1 = 2;    /* connecting first led to pin 2. */
int led2 = 3;    /* connecting second led to pin 3. */
int led3 = 4;    /* connecting third led to pin 4. */
int led4 = 5;    /* connecting forth led to pin 5. */
int led5 = 6;    /* connecting fifth led to pin 6. */
int led6 = 7;    /* connecting sixth led to pin 7. */
int led7 = 8;    /* connecting seventh led to pin 8. */
int led8 = 9;    /* connecting eights led to pin 9. */
int led9 = 10;   /* connecting ninth led to pin 10. */
int led10 = 11;  /* connecting tenth led to pin 11. */

void setup() {
  /* Set the LEDs pins as output. */
  
  pinMode(led1,OUTPUT);
   pinMode(led2,OUTPUT);
    pinMode(led3,OUTPUT);
     pinMode(led4,OUTPUT);
      pinMode(led5,OUTPUT);
       pinMode(led6,OUTPUT);
        pinMode(led7,OUTPUT);
         pinMode(led8,OUTPUT);
          pinMode(led9,OUTPUT);
           pinMode(led10,OUTPUT);

 /* Start communication. */
OneSheeld.begin();
}

void loop() {
value = Slider.getValue();  /* get the slider value and keep it in the "value" variable. */
value = map(value,0,255,0,10);  /* mapping the analog values of slider into values between 0 and 10 -*/ 
                                /*so the music volume will understand it. */

switch (value)  /*switch between the values to determine whicch leds to turn on and which to turn off.*/

{
 case 1:
        digitalWrite(led1,HIGH); 
        digitalWrite(led2,LOW);
        digitalWrite(led3,LOW);
        digitalWrite(led4,LOW);
        digitalWrite(led5,LOW);
        digitalWrite(led6,LOW);
        digitalWrite(led7,LOW);
        digitalWrite(led8,LOW);
        digitalWrite(led9,LOW);
        digitalWrite(led10,LOW);

        break;

  case 2:
        digitalWrite(led1,HIGH); 
        digitalWrite(led2,HIGH);
        digitalWrite(led3,LOW);
        digitalWrite(led4,LOW);
        digitalWrite(led5,LOW);
        digitalWrite(led6,LOW);
        digitalWrite(led7,LOW);
        digitalWrite(led8,LOW);
        digitalWrite(led9,LOW);
        digitalWrite(led10,LOW);

         break;

case 3:
        digitalWrite(led1,HIGH); 
        digitalWrite(led2,HIGH);
        digitalWrite(led3,HIGH);
        digitalWrite(led4,LOW);
        digitalWrite(led5,LOW);
        digitalWrite(led6,LOW);
        digitalWrite(led7,LOW);
        digitalWrite(led8,LOW);
        digitalWrite(led9,LOW);
        digitalWrite(led10,LOW);

         break;

 
case 4:
        digitalWrite(led1,HIGH); 
        digitalWrite(led2,HIGH);
        digitalWrite(led3,HIGH);
        digitalWrite(led4,HIGH);
        digitalWrite(led5,LOW);
        digitalWrite(led6,LOW);
        digitalWrite(led7,LOW);
        digitalWrite(led8,LOW);
        digitalWrite(led9,LOW);
        digitalWrite(led10,LOW);

         break;

case 5:
        digitalWrite(led1,HIGH); 
        digitalWrite(led2,HIGH);
        digitalWrite(led3,HIGH);
        digitalWrite(led4,HIGH);
        digitalWrite(led5,HIGH);
        digitalWrite(led6,LOW);
        digitalWrite(led7,LOW);
        digitalWrite(led8,LOW);
        digitalWrite(led9,LOW);
        digitalWrite(led10,LOW);

         break;

case 6:
        digitalWrite(led1,HIGH); 
        digitalWrite(led2,HIGH);
        digitalWrite(led3,HIGH);
        digitalWrite(led4,HIGH);
        digitalWrite(led5,HIGH);
        digitalWrite(led6,HIGH);
        digitalWrite(led7,LOW);
        digitalWrite(led8,LOW);
        digitalWrite(led9,LOW);
        digitalWrite(led10,LOW);

         break;

   
  case 7:
        digitalWrite(led1,HIGH); 
        digitalWrite(led2,HIGH);
        digitalWrite(led3,HIGH);
        digitalWrite(led4,HIGH);
        digitalWrite(led5,HIGH);
        digitalWrite(led6,HIGH);
        digitalWrite(led7,HIGH);
        digitalWrite(led8,LOW);
        digitalWrite(led9,LOW);
        digitalWrite(led10,LOW);

         break;


 case 8:
        digitalWrite(led1,HIGH); 
        digitalWrite(led2,HIGH);
        digitalWrite(led3,HIGH);
        digitalWrite(led4,HIGH);
        digitalWrite(led5,HIGH);
        digitalWrite(led6,HIGH);
        digitalWrite(led7,HIGH);
        digitalWrite(led8,HIGH);
        digitalWrite(led9,LOW);
        digitalWrite(led10,LOW);

         break;


 case 9:
        digitalWrite(led1,HIGH); 
        digitalWrite(led2,HIGH);
        digitalWrite(led3,HIGH);
        digitalWrite(led4,HIGH);
        digitalWrite(led5,HIGH);
        digitalWrite(led6,HIGH);
        digitalWrite(led7,HIGH);
        digitalWrite(led8,HIGH);
        digitalWrite(led9,HIGH);
        digitalWrite(led10,LOW);

         break;

    
    case 10:
        digitalWrite(led1,HIGH); 
        digitalWrite(led2,HIGH);
        digitalWrite(led3,HIGH);
        digitalWrite(led4,HIGH);
        digitalWrite(led5,HIGH);
        digitalWrite(led6,HIGH);
        digitalWrite(led7,HIGH);
        digitalWrite(led8,HIGH);
        digitalWrite(led9,HIGH);
        digitalWrite(led10,HIGH);

         break;
         default:      
         digitalWrite(led1,LOW); 
        digitalWrite(led2,LOW);
        digitalWrite(led3,LOW);
        digitalWrite(led4,LOW);
        digitalWrite(led5,LOW);
        digitalWrite(led6,LOW);
        digitalWrite(led7,LOW);
        digitalWrite(led8,LOW);
        digitalWrite(led9,LOW);
        digitalWrite(led10,LOW);


}


MusicPlayer.setVolume(value);  /*send the value of slider to the music volume.*/
 MusicPlayer.play();            /* Turn on the music. */
 
 
}

Schematics

1sheeld with ledbar schematic
1%20sheeld%20with%20led%20bar

Comments

Similar projects you might like

How can you Report Thief with a Photo on Twitter by Arduino

Project tutorial by ahmed ismail

  • 1,401 views
  • 0 comments
  • 8 respects

Home Automation using Arduino and 1Sheeld

Project tutorial by Ramy ElMallah

  • 4,286 views
  • 2 comments
  • 12 respects

Simple Door Prank with Arduino 1Sheeld

Project tutorial by Zowail

  • 902 views
  • 0 comments
  • 5 respects

4x4x4 LED cube with Arduino Uno and 1sheeld

Project tutorial by Hassan Ibrahim

  • 29,722 views
  • 6 comments
  • 60 respects

SMS based Home Automation system using 1SHEELD

Project tutorial by Tanishq Jaiswal

  • 27,240 views
  • 11 comments
  • 63 respects

Blind Stick Navigator

Project tutorial by Team MeRo

  • 10,215 views
  • 6 comments
  • 23 respects
Add projectSign up / Login