buongiorni,
sto provando ha scrivare un programma in cui comando un piccolo servo sotto input di un'IR, il programma l'ho finito ma non funziona, avete qualche idea?
vi lascio il programma, grazie.
//www.elegoo.com
//2016.12.12
#include "IRremote.h"
#include <Servo.h>
Servo myservo;
int pinLedV=4;
int pinLedR=5;
int receiver = 12;
int pos = 0;
IRrecv irrecv(receiver);
decode_results results;
void setup()
{
myservo.attach(9);
irrecv.enableIRIn();
pinMode(pinLedV, OUTPUT);
pinMode(pinLedR, OUTPUT);
}
void loop()
{
digitalWrite(pinLedR,HIGH);
digitalWrite(pinLedV,LOW);
if (irrecv.decode(&results)) // have we received an IR signal?
{
switch(results.value)
{
case 0xFFA857: // VOL+ button pressed
for (pos = 0; pos <= 50; pos += 1) {
myservo.write(pos);
}
case 0xFF629D: // VOL- button pressed
digitalWrite(pinLedV,HIGH);
digitalWrite(pinLedR, LOW);
for (pos = 0; pos <= 50; pos += 1) {
myservo.write(pos);
}
}
irrecv.resume();
}
}/* --end main loop -- */