I'm a beginner with arduino / arduino coding, got some stuff to play and learn with it, i'm stuck with something.
I wanna run code for a IR Remote to control a servo when i press the (+) button on the remote the servo start going to 180 degree but like one degree each press, like the volume thing on TV
i tried alot of thing with leds, servos from my background knowledge about simple stuff of programming and using some search help
i got almost everything work and fine i understand it
i came up with this
if (results.value == plus)
{
angel = angel+1;
Serial.println (angel);
}
what's in my mind is to make the angel write to the servo and everytime it get a +1
I decided to make it print so i see what's going on, when i call the function on loop it keep going to infinite if i pressed the button once
and including the func on setup don't recognize anything or run at all
Here's the full code including some led stuff i was trying
#include <IRremote.h>
#include <Servo.h>
#define on 0xFF6897
#define off 0xFF30CF
#define plus 0xFF906F
Servo servo;
int ir = 11;
int led = 13;
int angel=0;
IRrecv irrecv(ir);
decode_results results;
void setup()
{
servo.attach(4);
pinMode(led, OUTPUT);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop()
{
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX);
irrecv.resume();
}
if (results.value == on)
{
digitalWrite(led, HIGH);
}
if (results.value == off)
{
digitalWrite(led, LOW);
}
servo_1();
}
void servo_1()
{
if (results.value == plus)
{
angel = angel+1;
Serial.println (angel);
}
}