Im currently working on an arduino project and was trying to get a disco light sequence working with push button speed control but I can't seem to get it to work here is my push button code im sorry if the code is a bit meessy i am new to arduino and i cant seem to get my code right please be patient if i dont understand what you are sugesting as i also am autistic so i dont get some things imediatly
pinMode(12, INPUT);
}
int del=1000;
void loop()
{
int val = digitalRead(12);
if(val==HIGH)
del = 500;
else if(val==LOW)
del = del;
And here is my disco lights code
void setup()
{
pinMode(13, OUTPUT);
pinMode(0, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
}
void loop()
{
val = analogRead(potp);
digitalWrite(13, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(13, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(7, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
delay(val+1);
val = analogRead(potp);
digitalWrite(7, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(7, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, HIGH);
val = analogRead(potp);
delay(val+100);;
val = analogRead(potp);
digitalWrite(10, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(13, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(13, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
delay(val+1);
val = analogRead(potp);
digitalWrite(13, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(13, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(7, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(7, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(7, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(13, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(13, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
delay(val+1);
val = analogRead(potp);
digitalWrite(13, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(13, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(7, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
delay(val+1);
val = analogRead(potp);
digitalWrite(7, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(7, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(8, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(9, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(10, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(11, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(0, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(13, HIGH);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
digitalWrite(13, LOW);
val = analogRead(potp);
delay(val+100);
val = analogRead(potp);
delay(val+1);
val = analogRead(potp);
digitalWrite(13, HIGH);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(0, HIGH);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(11, HIGH);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(10, HIGH);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(9, HIGH);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(8, HIGH);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(7, HIGH);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
delay(val+1);
val = analogRead(potp);
digitalWrite(7, LOW);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(8, LOW);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(9, LOW);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(10, LOW);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(11, LOW);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(0, LOW);
val = analogRead(potp);
delay(val+1000);
val = analogRead(potp);
digitalWrite(13, LOW);
val = analogRead(potp);
delay(val+1000);
}