Project showcase
Servo Control with TV Remote Control

Servo Control with TV Remote Control © GPL3+

Using servo motor control with a TV remote control.

  • 5,591 views
  • 5 comments
  • 17 respects

Components and supplies

Apps and online services

About this project

I made a project where I control a servo motor with a TV remote control.

If you press "0" you set the servo at minimum angle. If you press "3" you set the maximum angle.

If you press "1" or "2" you set the servo +10 or -10 degrees, and print LCD angle value.

Code

CodeC/C++
#include <IRremote.h>
#include <IRremoteInt.h>

#include <Servo.h>

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // LCD screen setup RS,E,D4,D5,D6,D7
int RECV_PIN=8;                         //IR pin
IRrecv irrecv(RECV_PIN);
decode_results results ;
Servo myservo;
int angle = 0;          //setup angle 

void setup()
{
  lcd.begin(16, 2);     //LCD 16*2
  myservo.attach(9);    //Servo pin
  myservo.write(angle); //write servo value=0
  irrecv.enableIRIn();  // enable IR

  lcd.setCursor(0, 0);  //this is a loading bar, not a nice code...but work:)
  lcd.print("Betoltes..."); //print the text
  delay(800);
  lcd.clear();
  lcd.print("Betoltes>");
  delay(400);
  lcd.clear();
  lcd.print("Betoltes>>");
  delay(400);
  lcd.clear();
  lcd.print("Betoltes>>>");
  delay(400);
  lcd.clear();
  lcd.print("Betoltes>>>>");
  delay(400);
  lcd.clear();
  lcd.print("Betoltes>>>>>");
  delay(400);
  lcd.clear();
  lcd.print("Betoltes>>>>>>");
  delay(400);
  lcd.clear();
  lcd.print("Betoltes>>>>>>>");
  delay(400);
  lcd.clear();
  lcd.print("Motor szoge:");  //print the text
  lcd.setCursor(0, 1);        //set cursor 2. line
  lcd.print(angle);           //print the servo value
}

void loop()
{
  
   if(irrecv.decode(&results))    //read ir code
  {
   translateIR();
   myservo.write(angle);

    if (angle>180)      //when servo angle value max print maximum text
   {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Motor szoge:");
    lcd.setCursor(0, 1);
    lcd.print("Maximum szog");
    angle = 190;
   }
    else if (angle<0)   //when servo angle value min print minimum text
   {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Motor szoge:");
    lcd.setCursor(0, 1);
    lcd.print("Minimum szog");
    angle = -10;
   }
     else               //print servo angle value
     {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Motor szoge:");
    lcd.setCursor(0, 1);
    lcd.print(angle);
     }
   irrecv.resume();
  }
}
 void translateIR()     //
 {
   switch(results.value) {
    case 0xFF6897:  //0 button
    angle = 0;      //set angle minimum value
    break;
     
    case 0xFF30CF:  //1 button
  angle = angle + 10; //increase angle value
    break;
    
    case 0xFF18E7:  //2 button
  angle = angle -10;  //decrease angle value
    break;
     
     case 0xFF7A85: //3 button
  angle = 180;      //set angle maximum value
    break;
     
    }
 }

Schematics

Scematich
Nevtelen 2 5budlaz5yt
Schematich
Nevtelen3 7klsdayrl0

Comments

Similar projects you might like

Servo Control Panel

Project tutorial by dancili

  • 1,287 views
  • 0 comments
  • 6 respects

Voice Control Bluetooth TV Remote

Project in progress by pravin.desai

  • 1,069 views
  • 0 comments
  • 5 respects

Control TV Using A Touch Remote

Project tutorial by the lonely programmer

  • 501 views
  • 2 comments
  • 5 respects

Control an LED with the Remote Control

Project showcase by Nicholas_N

  • 3,827 views
  • 2 comments
  • 11 respects
Add projectSign up / Login