Hi,
You need to copy and paste your code from that site into code tags on here. OPs code:
#include "Wire.h"
#include <IRremote.h>
#include <LiquidCrystal_I2C.h> //#include <LiquidCrystal.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
// -------- Relay ----------
#define ON 1
#define OFF 0
#define address 0x20 // i2c slave address from 0x20 to 0x27
unsigned char i;
unsigned char variable_LOW;
unsigned char variable_HIGH;
unsigned int mode_byte; // 16bit unsigned variable
unsigned int FAST;
// -------- Remote ----------
int receiver = 11; // the pin where you connect the output pin of sensor
//int all = 0;
int relay1 = 0;
int relay2 = 0;
int relay3 = 0;
int relay4 = 0;
int relay5 = 0;
int relay6 = 0;
int relay7 = 0;
int relay8 = 0;
int relay = relay1 + relay2 + relay3 + relay4 + relay5 + relay6 + relay7 + relay8;
//int totalCount = 8;
#define code1 0xC // code received from button no. 1
#define code2 0x18 // code received from button no. 2
#define code3 0x5E // code received from button no. 3
#define code4 0x8 // code received from button no. 4
#define code5 0x1C // code received from button no. 5
#define code6 0x5A // code received from button no. 6
#define code7 0x42 // code received from button no. 7
#define code8 0x52 // code received from button no. 8
#define codeP 0x45 // code received from button no. 8
// -------- LCD ----------
/* NON I2C SET UP initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
//const int rs = 2, e = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
//LiquidCrystal lcd(rs, e, d4, d5, d6, d7); */
// LCD screen configuration function for the progress bar.
// Use custom characters 0 to 5 (6 and 7 remain available).
// These 5 arrays paint the bars that go across the screen.
byte zero[] = {
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000
};
byte one[] = {
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000
};
byte two[] = {
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000
};
byte three[] = {
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100
};
byte four[] = {
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110
};
byte five[] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
};
// END LCD SET UP
void setup() {
// START Relay Setup
Wire.begin(); // wake up I2C bus
Wire.beginTransmission(0x20);
Wire.write(0x00); // A register
Wire.write(0x00); // set all of port A to outputs
Wire.endTransmission();
Wire.beginTransmission(0x20);
Wire.write((byte)0x01); // B register
Wire.write((byte)0x00); // set all of port B to outputs
Wire.endTransmission();
FAST = 500;
//END Relay Setup
// START IR Setup
Serial.begin(115200);
Serial.println("IR Receive Test");
IrReceiver.begin(receiver, ENABLE_LED_FEEDBACK);
// END IR Setup
// START LCD Setup
lcd.init(); //changing from lcd.begin(16,2) to the init worked but i dont know why
lcd.backlight();
lcd.setCursor(0,0); //Position the text will be displayed
lcd.print("Gyro Test");
lcd.setCursor(0,1);
lcd.print(" By Arianne ");
delay(3000);
lcd.clear();
// initialize the LCD and allocate the 5 arrays to a number (Save custom characters in LCD display memory)
lcd.createChar(0, zero);
lcd.createChar(1, one);
lcd.createChar(2, two);
lcd.createChar(3, three);
lcd.createChar(4, four);
lcd.createChar(5, five);
// END LCD Setup
}
// This function control each channel separately ON/OFF
void ch_mode(unsigned char addr, unsigned int channel, unsigned char mode){
switch (channel) { case 16 : channel = 7; break;
case 15 : channel = 6; break;
case 14 : channel = 5; break;
case 13 : channel = 4; break;
case 12 : channel = 3; break;
case 11 : channel = 2; break;
case 10 : channel = 1; break;
case 9 : channel = 0; break;
case 8 : channel = 15; break;
case 7 : channel = 14; break;
case 6 : channel = 13; break;
case 5 : channel = 12; break;
case 4 : channel = 11; break;
case 3 : channel = 10; break;
case 2 : channel = 9; break;
case 1 : channel = 8; break; }
mode_byte &= ~(1<<(channel));
mode_byte |= mode<<channel;
variable_LOW = lowByte(mode_byte);
variable_HIGH = highByte(mode_byte);
Wire.beginTransmission(addr);
Wire.write(0x12); // address bank A
Wire.write(variable_LOW);
Wire.endTransmission();
Wire.beginTransmission(addr);
Wire.write(0x13); // address bank B
Wire.write(variable_HIGH);
Wire.endTransmission();
}
// This is the method that does all the work on the progress bar.
void updateProgressBar(unsigned long count, int totalCount, int lineToPrintOn) //total count is the total number to count to
{
double factor = totalCount/80.0; //Because I am using a 16 x 2 display, I have 16 characters. Each character has 5 sections. Therefore, I need to declare the number 80.0.
int percent = (count+1)/factor; // count is the current number in the count progress
int relay = percent/5;
int remainder = percent%5;
if(relay > 0)
{
lcd.setCursor(relay-1,lineToPrintOn);
lcd.write(5);
}
lcd.setCursor(relay,lineToPrintOn);
lcd.write(remainder);
}
/*void draw_progressbar (byte percent) {
// Display the new value in numeric form on the first line
lcd.setCursor (0,0);
lcd.print (percent);
lcd.print (F ( "%" ));
// NB The two spaces at the end of the line are used to erase the digits of the previous percentage
// when going from a value with two or three digits to a value with two or one digits.
lcd.setCursor (0,1);
// Map range (0 ~ 100) to range (0 ~ LCD_NB_COLUMNS * 5)
byte nb_columns = map (percent, 0 , 100 , 0 , LCD_NB_COLUMNS * 5 );
//Draw each character in the line
for (byte i = 0 ; i < LCD_NB_COLUMNS; ++ i) {
//Depending on the number of columns remaining to display
if (nb_columns == 0 ) { // Empty case
lcd.write ((byte) 0 );
} else if (nb_columns >= 5 ) { // Full case
lcd.write ( 5 );
nb_columns -= 5 ;
} else { // Last box not empty
lcd.write (nb_columns);
nb_columns = 0 ;
}
}
}*/
void loop()
{
if (IrReceiver.decode()) // have we received an IR signal?
{
switch (IrReceiver.decodedIRData.command)
{
case code1: /* == RELAY 1 RED ==*/
ch_mode(address,1,!relay1);
//relay1 != relay1; for some reason this only turned off but not back on
relay1 = 1- relay1;
break;
case code2: /* == RELAY 2 BLUE ==*/
ch_mode(address,2,!relay2);
//relay2 != relay2;
relay2 = 1-relay2;
break;
case code3: /* == RELAY 3 YELLOW ==*/
ch_mode(address,3,!relay3);
//relay3 != relay3;
relay3 = 1-relay3;
break;
case code4: /* == RELAY 4 GREEN ==*/
ch_mode(address,4,!relay4);
//relay4 != relay4;
relay4 = 1-relay4;
break;
case code5: /* == RELAY 5 RED ==*/
ch_mode(address,5,!relay5);
//relay5 != relay5;
relay5 = 1-relay5;
break;
case code6: /* == RELAY 6 BLUE ==*/
ch_mode(address,6,!relay6);
//relay6 != relay6;
relay6 = 1-relay6;
break;
case code7: /* == RELAY 7 YELLOW ==*/
ch_mode(address,7,!relay7);
//relay7 != relay7;
relay7 = 1-relay7;
break;
case code8: /* == RELAY 8 GREEN ==*/
ch_mode(address,8,!relay8);
//relay8 != relay8;
relay8 = 1-relay8;
break;
case codeP: // All off or all on
//Other attempts in notepad file
if (relay1 + relay2 + relay3 + relay4 + relay5 + relay6 + relay7 + relay8 >= 1)
{
ch_mode(address,8,OFF);
ch_mode(address,7,OFF);
ch_mode(address,6,OFF);
ch_mode(address,5,OFF);
ch_mode(address,4,OFF);
ch_mode(address,3,OFF);
ch_mode(address,2,OFF);
ch_mode(address,1,OFF);
relay8 = 0;
relay7 = 0;
relay6 = 0;
relay5 = 0;
relay4 = 0;
relay3 = 0;
relay2 = 0;
relay1 = 0;
}
else if (relay1 + relay2 + relay3 + relay4 + relay5 + relay6 + relay7 + relay8 == 0)
{
ch_mode(address,8,ON);
ch_mode(address,7,ON);
ch_mode(address,6,ON);
ch_mode(address,5,ON);
ch_mode(address,4,ON);
ch_mode(address,3,ON);
ch_mode(address,2,ON);
ch_mode(address,1,ON);
relay8 = 1;
relay7 = 1;
relay6 = 1;
relay5 = 1;
relay4 = 1;
relay3 = 1;
relay2 = 1;
relay1 = 1;
}
break;
default:
break;
}
delay(FAST);
IrReceiver.resume();
outputRemote();
}
/* ============ LCD START ============= */
if (/*relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == i &&*/ relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == 1)
{
lcd.setCursor(1,0);
//lcd.print("One LED");
//lcd.print(" ");
updateProgressBar(10, 100, 0); //This line calls the subroutine that displays the progress bar. The 3 arguments are the current count, the total count and the line you want to print on.
delay(200);
}
delay(1000);
if (/*relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == i &&*/ relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == 2)
{
lcd.setCursor(2,0);
//lcd.print("Two LED");
//lcd.print(" ");
updateProgressBar(20, 100, 0); //This line calls the subroutine that displays the progress bar. The 3 arguments are the current count, the total count and the line you want to print on.
delay(200);
}
delay(1000);
if (/*relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == i &&*/ relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == 3)
{
lcd.setCursor(3,0);
//lcd.print("3 LED");
//lcd.print(" ");
updateProgressBar(30, 100, 0); //This line calls the subroutine that displays the progress bar. The 3 arguments are the current count, the total count and the line you want to print on.
delay(200);
}
delay(1000);
if (/*relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == i &&*/ relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == 4)
{
lcd.setCursor(4,0);
//lcd.print("4 LED");
//lcd.print(" ");
updateProgressBar(40, 100, 0); //This line calls the subroutine that displays the progress bar. The 3 arguments are the current count, the total count and the line you want to print on.
delay(200);
}
delay(1000);
if (/*relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == i &&*/ relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == 5)
{
lcd.setCursor(5,0);
//lcd.print("Two LED");
//lcd.print(" ");
updateProgressBar(50, 100, 0); //This line calls the subroutine that displays the progress bar. The 3 arguments are the current count, the total count and the line you want to print on.
delay(200);
}
delay(1000);
if (/*relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == i &&*/ relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == 6)
{
lcd.setCursor(6,0);
//lcd.print("Two LED");
//lcd.print(" ");
updateProgressBar(60, 100, 0); //This line calls the subroutine that displays the progress bar. The 3 arguments are the current count, the total count and the line you want to print on.
delay(200);
}
delay(1000);
if (/*relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == i &&*/ relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == 7)
{
lcd.setCursor(7,0);
//lcd.print("Two LED");
//lcd.print(" ");
updateProgressBar(70, 100, 0); //This line calls the subroutine that displays the progress bar. The 3 arguments are the current count, the total count and the line you want to print on.
delay(200);
}
delay(1000);
if (relay1 + relay2 + relay3 + relay4 + relay5 +relay6 + relay7 + relay8 == 8)
{
lcd.setCursor(8,0);
updateProgressBar(80, 100, 0); //This line calls the subroutine that displays the progress bar. The 3 arguments are the current count, the total count and the line you want to print on.
delay(200);
}
delay(1000);
/* ============ LCD END ============= */
}
void outputRemote() // describing Remote IR codes
{
switch(IrReceiver.decodedIRData.command)
{
case 0x45: Serial.println("POWER"); break;
case 0x47: Serial.println("FUNC/STOP"); break;
case 0x46: Serial.println("VOL+"); break;
case 0x44: Serial.println("REWIND"); break;
case 0x40: Serial.println("PAUSE"); break;
case 0x43: Serial.println("FAST FORWARD"); break;
case 0x7: Serial.println("DOWN"); break;
case 0x15: Serial.println("VOL-"); break;
case 0x9: Serial.println("UP"); break;
case 0x19: Serial.println("EQ"); break;
case 0xD: Serial.println("ST/REPT"); break;
case 0x16: Serial.println("0"); break;
case 0xC: Serial.println("1"); break;
case 0x18: Serial.println("2"); break;
case 0x5E: Serial.println("3"); break;
case 0x8: Serial.println("4"); break;
case 0x1C: Serial.println("5"); break;
case 0x5A: Serial.println("6"); break;
case 0x42: Serial.println("7"); break;
case 0x52: Serial.println("8"); break;
case 0x4A: Serial.println("9"); break;
default:
Serial.println(" other button ");
} //END Switch
delay(FAST); // Do not get immediate repeat
Serial.print("Relay One: ");
Serial.println(digitalRead (relay1));
Serial.print("Relay Two: ");
Serial.println(digitalRead (relay2));
Serial.print("Relay Three: ");
Serial.println(digitalRead (relay3));
Serial.print("Relay Four: ");
Serial.println(digitalRead (relay4));
Serial.print("Relay Five: ");
Serial.println(digitalRead (relay5));
Serial.print("Relay Six: ");
Serial.println(digitalRead (relay6));
Serial.print("Relay Seven: ");
Serial.println(digitalRead (relay7));
Serial.print("Relay Eight: ");
Serial.println(digitalRead (relay8));
}