I know this is a simple project but I am new at this and I am having trouble finding a build, and code that works. My original build was on the Uno and it work well, but I was able to use the <IRremote.h> which will not work on the gemma. This is the code I used there.
#include <IRremote.h>
const int IR_Pin = 2;
const int motorPin = 9;
int switchPin = LOW;
IRrecv irrecv(IR_Pin);
decode_results results;
void setup() {
Serial.begin (9600);
irrecv.enableIRIn();//starts the reciever
pinMode(motorPin, OUTPUT);
pinMode(switchPin, INPUT);
}
void loop() {
if (irrecv.decode(&results)){
long int decCode = results.value;
Serial.println(decCode);
switch(results.value){
case 16744575:
Serial.println("Turn On!");
delay(500);
digitalWrite(motorPin, HIGH);
break;
case 16748655:
Serial.println("Turn Off!");
delay(500);
digitalWrite(motorPin, LOW);
break;
default:
Serial.println("What's Gonna Happen?");
}
irrecv.resume(); //Receices the next value from the button you press.
}
}
I have also tried the two tutorials from adafruit
With the first one both of my gemmas were turning on and off, and the serial print was not working. The second on I tried to adapt it for the gemma to no avail.
So does anyone have a project they did for IR communication with the gemma. Any advice would be great. Thank you.