Witam ponownie
Dzisiaj przychodzę do was z innym problemem
Zrobiłem układ który po wciśnięciu przycisku zapala diode przez ustawiony czas na potencjometrze( na dole macie mój kod, pewnie łatwiej go zrobić ale dopiero się uczę:) ). Problem polega na tym, że jak sprawdzałem kod na arduino to wszystko działało dobrze, po wgraniu na atmege dioda miga jak szalona ( zamiast nastawionego czasu świeci się jak chce). Moim zdaniem mam problem z zakłóceniami i moje pytanie brzmi jak mogę je wyeliminować?:D
Poniżej daje schemat ( układ jest łączony linkami 20cm jakich się używa do płytek)
Kod:
int dane = 0;
void setup() {
// put your setup code here, to run once:
pinMode(8, OUTPUT);
pinMode(7, INPUT_PULLUP);
digitalWrite(8, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
dane = analogRead(A5);
dane = map(dane, 3, 1021, 1, 23);
switch (dane) {
case 1:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(700);
break;
}
case 2:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(150);
digitalWrite(8, LOW);
delay(700);
break;
}
case 3:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(200);
digitalWrite(8, LOW);
delay(700);
break;
}
case 4:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(250);
digitalWrite(8, LOW);
delay(700);
break;
}
case 5:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(300);
digitalWrite(8, LOW);
delay(700);
break;
}
case 6:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(350);
digitalWrite(8, LOW);
delay(700);
break;
}
case 7:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(400);
digitalWrite(8, LOW);
delay(700);
break;
}
case 8:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(450);
digitalWrite(8, LOW);
delay(700);
break;
}
case 9:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
delay(700);
break;
}
case 10:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(550);
digitalWrite(8, LOW);
delay(700);
break;
}
case 11:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(600);
digitalWrite(8, LOW);
delay(700);
break;
}
case 12:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(650);
digitalWrite(8, LOW);
delay(700);
break;
}
case 13:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(700);
digitalWrite(8, LOW);
delay(700);
break;
}
case 14:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(750);
digitalWrite(8, LOW);
delay(700);
break;
}
case 15:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(800);
digitalWrite(8, LOW);
delay(700);
break;
}
case 16:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(850);
digitalWrite(8, LOW);
delay(700);
break;
}
case 17:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(900);
digitalWrite(8, LOW);
delay(700);
break;
}
case 18:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(950);
digitalWrite(8, LOW);
delay(700);
break;
}
case 19:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(8, LOW);
delay(700);
break;
}
case 20:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(1050);
digitalWrite(8, LOW);
delay(700);
break;
}
case 21:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(1100);
digitalWrite(8, LOW);
delay(700);
break;
}
case 22:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(1150);
digitalWrite(8, LOW);
delay(700);
break;
}
case 23:
if (digitalRead(7) == LOW)
{
digitalWrite(8, HIGH);
delay(1200);
digitalWrite(8, LOW);
delay(700);
break;
}
}
}