// main code: ArduinoCode.ino
int full = 255;
int mid = 50;
int off = 0;
int command;
// CLASS + OBJECTS;
#include <IRremote.h>
#define PIN_RECEIVER 2 // Signal Pin of IR receiver
IRrecv receiver(PIN_RECEIVER);
// CLASS + OBJECTS;
#include "LED.h"
//create a LED object that attach to pin
LED rgbledG(5,50);
LED rgbledR(6,50);
LED rgbledB(3,50);
LED indicatorledLEFT (12,0);
LED indicatorledRIGHT (11,0);
LED reverseled (4,0);
LED rear (9,50);
LED dud ( 8,0);
// CLASS OBJECTS;
#include "FEATURES.h"
// create a class object that attach to vaiables
FEATURES smooth(60, 1, 8); //6seconds of smooth rotation through colours
FEATURES gradual(61, 125, 1000); //6seconds of 6colour blends of RGB Dsiplay
FEATURES jump(62, 250, 2000); //6seconds of 3colour RGB display
FEATURES onofflong(63, 0, 15000); //15seconds display
FEATURES onoffshort(64, 0, 750); //2seconds display
FEATURES onoffstrobe(65, 0, 500); //half second pulse
void setup() {
// put your setup code here, to run once:
//Serial.begin(9600); ////can be activated for test and debug
Serial.begin(9600);
Serial.print("<press a button>");
receiver.enableIRIn(); // Start the receiver
}
void loop() {
// Checks received an IR signal
if (receiver.decode()) {
translateIR();
receiver.resume(); // Receive the next value
}
// put your main code here, to run repeatedly:
}
void Serialprint(char* text)
{
Serial.print("button pressed:");
Serial.print(text);
Serial.print(" code: ");
Serial.print(receiver.decodedIRData.command);
}
void translateIR()
{
// Takes command based on IR code received
switch (receiver.decodedIRData.command) {
/* case 162:
Serialprint("POWER");
break;
case 226:
Serialprint("MENU");
break;
case 34:
Serialprint("TEST");
break;
case 2:
Serialprint("PLUS");
break;
case 194:
Serialprint("BACK");
break;
case 224:
Serialprint("PREV.");
break;
case 168:
Serialprint("PLAY");
break;
case 144:
Serialprint("NEXT");
break;
case 104:
Serialprint("num: 0");
break;
case 152:
Serialprint("MINUS");
break;
case 176:
Serialprint("key: C");
break;*/
case 48:
Serialprint("num: 1");
//(int LG, int FG, int LR, int FR, int LB, int FB)
smooth.THREEcolourRotation(rgbledG.getPin(), rgbledG.getlightVAL(),rgbledR.getPin(), rgbledR.getlightVAL(),rgbledB.getPin(), rgbledB.getlightVAL());
break;
case 24:
Serialprint("num: 2");
//FRONT FULL
analogWrite(rear.getPin(),mid);
digitalWrite(reverseled.getPin(), LOW);
rgbledB.setlightVAL(full);
rgbledG.setlightVAL(full);
rgbledR.setlightVAL(full);
delay(500);
break;
/* case 122:
Serialprint("num: 3");
break; */
case 16:
Serialprint("num: 4");
digitalWrite(indicatorledLEFT.getPin(), full);
delay(500);
digitalWrite(indicatorledLEFT.getPin(), off);
delay(500);
break;
case 56:
Serialprint("num: 5");
analogWrite(rear.getPin(),full);
digitalWrite(reverseled.getPin(), LOW);
break;
case 90:
Serialprint("num: 6");
digitalWrite(indicatorledRIGHT.getPin(), full);
delay(500);
digitalWrite(indicatorledRIGHT.getPin(), off);
delay(500);
break;
case 66:
Serialprint("num: 7");
onoffshort.whitelight( indicatorledLEFT.getPin(), full, indicatorledRIGHT.getPin(), full,dud.getPin(), full);
delay(500);
onoffshort.whitelight( indicatorledLEFT.getPin(), full, indicatorledRIGHT.getPin(), full,dud.getPin(), full);
delay(500);
break;
case 74:
Serialprint("num: 8");
analogWrite(rear.getPin(),mid);
digitalWrite(reverseled.getPin(), HIGH);
delay(500);
break;
case 82:
Serialprint("num: 9");
analogWrite( rgbledB.getPin(), full); analogWrite(rgbledG.getPin(), off); analogWrite(rgbledR.getPin(), off);
delay(500);
analogWrite( rgbledB.getPin(), rgbledB.getlightVAL()); analogWrite(rgbledG.getPin(),rgbledG.getlightVAL()); analogWrite(rgbledR.getPin(), rgbledR.getlightVAL());
delay(500);
break;
default:
jump.RUNNINGLIGHTSlight(rgbledB.getPin(), rgbledB.getlightVAL());
jump.RUNNINGLIGHTSlight(rgbledG.getPin(), rgbledG.getlightVAL());
jump.RUNNINGLIGHTSlight(rgbledR.getPin(), rgbledR.getlightVAL());
analogWrite(rear.getPin(),mid);
delay(500);
//REAR
Serial.print(receiver.decodedIRData.command);
Serial.print(" other button");
}
}