void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
Serial.begin(9600);
}
// 50 % Duty cant
int Duty = 0;
int tOn = 0;
int tOn1 = 0;
int tOff = 0;
int tOff1 = 0;
int PerCent = 100;
int d = 1000;
void loop(){
for (int Duty = 0; Duty < 255; Duty ++){
//Serial.write(Duty);
tOn = (PerCent - Duty);
tOn1 = tOn * d ;
tOff = (PerCent - tOn);
tOff1 = tOff * d;
digitalWrite(13, HIGH);
delayMicroseconds(tOn1);
digitalWrite(13,LOW);
delayMicroseconds(tOff1);
tOn1 = 0;
tOff1 = 0;
}
for (int Duty = 255; Duty > -1 ; Duty --){
Serial.write(Duty);
tOn = ((PerCent - Duty) );
tOn1 = tOn * d;
tOff = ((PerCent - tOn) );
tOff1 = tOff * d;
digitalWrite(13,HIGH);
delayMicroseconds(tOn1);
digitalWrite(13,LOW);
delayMicroseconds(tOff1);
tOn1 = 0;
tOff1 = 0;
}//
//delay(500);
//Serial.write(Duty);
}