Умные дневные ходовые огни

cvbs

✩✩✩✩✩✩✩
25 Сен 2018
2
0
схема работает не получается сделать плавный розжиг и затухание на выходах ДХО











byte i = 0;

const int led1Pin = 5; // левый ДХО


const int led2Pin = 6; // правый ДХО


unsigned long led1OnTime;


unsigned long led2OnTime;


bool led1On;


bool led2On;


void setup() {


pinMode(led1Pin, OUTPUT);

digitalWrite(5, HIGH);

pinMode(led2Pin, OUTPUT);

digitalWrite(6, HIGH);

pinMode(button1Pin, INPUT);
pinMode(buttongPin, INPUT);
pinMode(buttonrPin, INPUT);
pinMode(button2Pin, INPUT);


led1On = false;


led2On = false;


}


void loop(){









if (digitalRead(button1Pin) == HIGH)

{


digitalWrite(led1Pin, LOW);


led1On = true;


led1OnTime = millis();


}


if (digitalRead(button2Pin) == HIGH) {


digitalWrite(led2Pin, LOW);


led2On = true;


led2OnTime = millis();


}

if (digitalRead(buttongPin) == HIGH) {


digitalWrite(led2Pin, LOW);


led2On = true;


led2OnTime = millis();


}

if (digitalRead(buttongPin) == HIGH) {


digitalWrite(led1Pin, LOW);


led1On = true;


led1OnTime = millis();


}




if (digitalRead(buttonrPin) == HIGH) {


digitalWrite(led2Pin, LOW);


led2On = true;


led2OnTime = millis();


}

if (digitalRead(buttonrPin) == HIGH) {


digitalWrite(led1Pin, LOW);


led1On = true;


led1OnTime = millis();


}















if(led1On)


if(millis() - led1OnTime > 2000)
{


digitalWrite(led1Pin,HIGH );


led1On = false;


}


if(led2On)


if(millis() - led2OnTime > 2000) {


digitalWrite(led2Pin, HIGH);


led2On = false;


}


}
 

cvbs

✩✩✩✩✩✩✩
25 Сен 2018
2
0
const int button1Pin = 8;
const int buttongPin = 4;
const int buttonrPin = 11;
const int button2Pin = 9;

byte i = 0;

const int led1Pin = 5;


const int led2Pin = 6;


unsigned long led1OnTime;


unsigned long led2OnTime;


bool led1On;


bool led2On;


void setup() {


pinMode(led1Pin, OUTPUT);

digitalWrite(5, HIGH);

pinMode(led2Pin, OUTPUT);

digitalWrite(6, HIGH);

pinMode(button1Pin, INPUT);
pinMode(buttongPin, INPUT);
pinMode(buttonrPin, INPUT);
pinMode(button2Pin, INPUT);


led1On = false;


led2On = false;


}


void loop(){









if (digitalRead(button1Pin) == HIGH)

{


digitalWrite(led1Pin, LOW);


led1On = true;


led1OnTime = millis();


}


if (digitalRead(button2Pin) == HIGH) {


digitalWrite(led2Pin, LOW);


led2On = true;


led2OnTime = millis();


}

if (digitalRead(buttongPin) == HIGH) {


digitalWrite(led2Pin, LOW);


led2On = true;


led2OnTime = millis();


}

if (digitalRead(buttongPin) == HIGH) {


digitalWrite(led1Pin, LOW);


led1On = true;


led1OnTime = millis();


}




if (digitalRead(buttonrPin) == HIGH) {


digitalWrite(led2Pin, LOW);


led2On = true;


led2OnTime = millis();


}

if (digitalRead(buttonrPin) == HIGH) {


digitalWrite(led1Pin, LOW);


led1On = true;


led1OnTime = millis();


}















if(led1On)


if(millis() - led1OnTime > 2000)
{


digitalWrite(led1Pin,HIGH );


led1On = false;


}


if(led2On)


if(millis() - led2OnTime > 2000) {


digitalWrite(led2Pin, HIGH);


led2On = false;


}


}
 

Turtoise

✩✩✩✩✩✩✩
31 Июл 2018
21
4
уверен что удобнее было бы спрятать все это под
и читать людям удобнее