hy
can someone help?
i have a problem ,stuck in project. Arduino uno .
i need a blinking led, maybye multitasking with potentiometer on analog input
example:
read A0 if 0 turn off
if
read A1 potentiometer, if read 1023 turn on
output pin 10,2,4,6
and flash led on pin 11 12
but when
A2 potentiometer read 1023 turn on
pin 10 ,2,3,7
and
A3 read 1023 turn on
pin 10,3,5,6
and
A4 read 1023 turn on pin 11,12
I coded each task separately, how to combine them,
put them in a row
CODING: (flash and output 10,2,4,6
void setup() {
pinMode(10,HIGH);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(A1, INPUT);
pinMode(02,HIGH);
pinMode(04,HIGH);
pinMode(06,HIGH);
}
void loop() {
if(analogRead(A1) > 1020) {
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(12,LOW);
delay(50);
digitalWrite(11,LOW);
delay(50);
digitalWrite(12,HIGH);
delay(100);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(12,LOW);
delay(50);
digitalWrite(11,LOW);
delay(50);
digitalWrite(12,HIGH);
delay(100);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(12,LOW);
delay(50);
digitalWrite(11,LOW);
delay(50);
digitalWrite(12,LOW);
delay(1000);
digitalWrite(11,LOW);
delay(1000);
digitalWrite(10,HIGH);
digitalWrite(02,HIGH);
digitalWrite(04,HIGH);
digitalWrite(06,HIGH);
delay(1000);
digitalWrite(10,LOW);
digitalWrite(02,LOW);
digitalWrite(04,LOW);
digitalWrite(06,LOW);
delay(1000);
}
else {
if(analogRead(A1) < 1020)
digitalWrite(12, LOW); //if it isn't higher than 512, make pin 4 low
}
}
CODING ( 10,3,5,6
void setup() {
pinMode(10,HIGH);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(A3, INPUT);
pinMode(05,HIGH);
pinMode(03,HIGH);
pinMode(06,HIGH);
}
void loop() {
if(analogRead(A3) > 1020) {
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(12,LOW);
delay(50);
digitalWrite(11,LOW);
delay(50);
digitalWrite(12,HIGH);
delay(100);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(12,LOW);
delay(50);
digitalWrite(11,LOW);
delay(50);
digitalWrite(12,HIGH);
delay(100);
digitalWrite(11,HIGH);
delay(100);
digitalWrite(12,LOW);
delay(50);
digitalWrite(11,LOW);
delay(50);
digitalWrite(12,LOW);
delay(1000);
digitalWrite(11,LOW);
delay(1000);
digitalWrite(10,HIGH);
digitalWrite(05,HIGH);
digitalWrite(03,HIGH);
digitalWrite(06,HIGH);
delay(1000);
digitalWrite(10,LOW);
digitalWrite(05,LOW);
digitalWrite(03,LOW);
digitalWrite(06,LOW);
delay(1000);
}
else {
if(analogRead(A3) < 1020)
digitalWrite(12, LOW); //if it isn't higher than 512, make pin 4 low
}
}
thanks