LCD16x2+ds1307+ time/pwm Problem

Hi i have a problem this program

Works fine, but i want set a led on and off in some times (ex: 13:45:00 on and 14:35:00 off)

If i use this

if(minute==55)
{
digitalWrite(8,255);
}
My lcd goes crazy

At high frequency of pwm… More 32Khz

So if i setPwmfrequency(6,1) dont work(I think that changes the parameters of the timer)

How i can solve this problem ?

The program -

// Connections:
// LCD pin 1 to Arduino GND
// LCD pin 2 to Arduino 5v
// LCD pin 3 (Contrast) to GND
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pin 16 to Arduino GND
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2

//Tested with DS1307 Breakout from Sparkfun
//pin SDA to Arduino Analog pin 4
//pin SCL to Arduino Analog pin 5
//pin GND to Arduino GND
//pin VCC to Arduino 5v

#include <Wire.h>
#define DS1307_I2C_ADDRESS 0x68
#include <LiquidCrystal.h> // we need this library for the LCD commands

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
int ledPin = 8;
int hora;
int backLight = 13; // pin 13 will control the backlight
int fadeValue = 0;
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
return ( (val/1016) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
return ( (val/16
10) + (val%16) );
}
// 1) Sets the date and time on the ds1307
// 2) Starts the clock
// 3) Sets hour mode to 24 hour clock
// Assumes you’re passing in valid numbers
void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour));
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.send(0x10); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave
Wire.endTransmission();
}
// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
// Reset the register pointer
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
// A few of these need masks because certain bits are control bits
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
Wire.begin();
Serial.begin(9600);
// Change these values to what you want to set your clock to.
// You probably only want to set your clock once and then remove
// the setDateDs1307 call.
second = 0;
minute = 53;
hour = 13;
dayOfWeek = 3;
dayOfMonth = 21;
month = 8;
year = 12;

//setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
lcd.begin(16, 2); // tells Arduino the LCD dimensions

}
void loop()

{

byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
lcd.clear(); // clear LCD screen
lcd.setCursor(0,0);
lcd.print(" “);
lcd.print(hour, DEC);
lcd.print(”:");
if (minute<10)
{
lcd.print(“0”);
}

lcd.print(minute, DEC);
lcd.print(":");
if (second<10)
{
lcd.print(“0”);
}
lcd.print(second, DEC);
lcd.setCursor(0,1);
lcd.print(" “);
switch(dayOfWeek){
case 1:
lcd.print(“Dom”);
break;
case 2:
lcd.print(“Seg”);
break;
case 3:
lcd.print(“Ter”);
break;
case 4:
lcd.print(“Qua”);
break;
case 5:
lcd.print(“Qui”);
break;
case 6:
lcd.print(“Sex”);
break;
case 7:
lcd.print(“Sab”);
break;
}
lcd.print(” “);
lcd.print(month, DEC);
lcd.print(”/");
lcd.print(dayOfMonth, DEC);
lcd.print("/20");
lcd.print(year, DEC);
delay(1000);

if(minute==54)
{
digitalWrite(8,128);
}

if(minute==55)
{
digitalWrite(8,255);
}

}

Tanks

The second argument to digitalWrite() is either HIGH or LOW. Neither of those values are 128 or 255. I don't know why you are trying to adjust PWM frequency, when pin 8 is not a PWM pin. At least not on a 328-based Arduino.

I'm using mega1280, i'm sorry, i dont see this big error, digital is 0 or 1.
Put analog and another pin, no more problems. Tanks