Gabriele00111
Published

Raise the Volume with Remote Controller

Use a remote controller to adjust the volume of the radio.

IntermediateFull instructions provided4,483
Raise the Volume with Remote Controller

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Infrared Receiver, Remote Control
Infrared Receiver, Remote Control
×1
RGB LCD Shield Kit, 16x2 Character Display
RGB LCD Shield Kit, 16x2 Character Display
×1
Breadboard (generic)
Breadboard (generic)
×1
Resistor 1k ohm
Resistor 1k ohm
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Circuit

Code

Code

Arduino
The libraries are in arduino except the <Irremote.h>, you need to download it for use on arduino.
#include <IRremote.h>
#include <Servo.h>
#include <LiquidCrystal.h>


Servo myservo;
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
int receiver = 10;
IRrecv irrecv(receiver);
decode_results results;
int code=0;
int x;
int cont=0;
int volume=0;
int y=0;

void setup()
{
  Serial.begin(9600); 
  irrecv.enableIRIn();
  myservo.attach(11); 
  lcd.begin(16, 2); 
  lcd.clear();
}
void loop()
{
  if (irrecv.decode(&results))
  {
    code=results.value;
    Serial.println(code, HEX);
    irrecv.resume();
    switch(code)
    { 
      case(0xFFFFA857):
      cont=1;
      x=x+3;
      break;
      case(0xFFFFE01F):
      cont=0;
      x=x-3;
      break;
      case(0xFFFFFFFF):
      if(cont==1)x=x+4;
      if(cont==0)x=x-4;
      break; 
      default;
      cont=2;
      break;

    }
    x=constrain(x,3,180);
    Serial.println(x);
    myservo.write(x);
    volume=map(x,3,180,0,100);
  }
  lcd.setCursor(8, 0);
  lcd.print("VOLUME:");
  lcd.setCursor(4, 1);
  lcd.print("%");
  lcd.setCursor(0, 1);
  lcd.print(volume);
  if(volume>80)
  {
    lcd.setCursor(7, 1);
    lcd.print("too high!");
  }
  delay(50);
  lcd.clear();
}

Credits

Gabriele00111

Gabriele00111

1 project • 0 followers

Comments