Hello, Im very new to the arduino world. I have only been playing with learning arduino for a couple weeks, but many hours in that time of research and trial and error!!
I have a working setup with an UNO controlling 4 relays with an Ir remote. I am trying to replace the UNO with a digispark attiny85 module. (micro usb) I cannot get a code working or find some one elses code to use. I am new to programming and unable to write my own yet. I am becoming more familiar the more I play of coarse though.
I tried to somewhat copy the working sketch that I use for the uno but using the libraries for the digi. I am having issues with keywords and library conflics. Can someone please help me with this. Once I get a working code I can study it of course.
Here is what I have so far.
#include <IRremote.h>
#include <IRremoteInt.h>
const int IR_PIN = 5;
const int RELAY_PINS[2] = {0, 1,};
int RELAY_STATES[2] = {LOW};
IRrecv irrecv(IR_PIN);
decode_results results;
void setup() {
irrecv.enableIRIn();
for (int i =0; i <2; i++) {
pinMode(RELAY_PINS[i], OUTPUT); //left out decode results
}
}
int jvcDecode(unsigned long irValue) {
switch (irValue) {
case 0xF1B1:
return 1;
case 0xF119:
return 2;
}
return -1;
}
void action(int button) {
if (button > 0 && button < 9) {
//toggle single relay
int i = button - 1;
if (RELAY_STATES[i] == LOW) {
digitalWrite(RELAY_PINS[i], HIGH);
RELAY_STATES[i] = HIGH;
} else {
digitalWrite(RELAY_PINS[i], LOW);
RELAY_STATES[i] = LOW;
}
} else if (button == 9) {
//switch ON all relays
for (int i = 0; i < 8; i++) {
digitalWrite(RELAY_PINS[i], HIGH);
RELAY_STATES[i] = HIGH;
}
} else if (button == 0) {
//switch OFF all relays
for (int i = 0; i < 8; i++) {
digitalWrite(RELAY_PINS[i], LOW);
RELAY_STATES[i] = LOW;
}
}
}
int lastPressedButton = -1;
void loop() {
if (irrecv.decode(&results)) {
int button = jvcDecode(results.value);
if (button != lastPressedButton) {
lastPressedButton = button;
action(button);
}
irrecv.resume();
} else {
lastPressedButton = -1;
}
delay(250);
}
C:\Users\Tyj\Documents\Arduino\libraries\IRremote\IRremoteInt.h:239:44: error: ‘OCIE2A’ was not declared in this scope
#define TIMER_ENABLE_INTR (TIMSK2 = _BV(OCIE2A))
^
C:\Users\Tyj\Documents\Arduino\libraries\IRremote\IRremote.cpp:309:3: note: in expansion of macro ‘TIMER_ENABLE_INTR’
TIMER_ENABLE_INTR;
^
exit status 1
Error compiling.