greetings to the masters;
sorry i'm a beginner, i have a problem with vocabulary in c ++ can you help simplify my coding
, here I want to make LEDs blink 2x for 2 times, and blink 3 times for 2 times.
and if value of analogValue > threshold(400) the process will stop without having to wait for everything to finish execution
thanks,
here my code:
///////////////////////////////////////////////////////////////////////////////////////////////
int potPin = A3; // select the input pin for the potentiometer
int timeFlash = 0; //
const int ledPin = 4;
const int analogPin = A1;
const int threshold = 200;
void setup() {
// initialize pin 4 (ATtiny leg 3) as an output.
Serial.begin(9600);
pinMode(4, OUTPUT);
pinMode(A3, INPUT);
pinMode(A1, INPUT);
}
void loop() {
timeFlash = analogRead(potPin);
int analogValue = analogRead(analogPin);
if (analogValue > threshold) {
digitalWrite(ledPin, LOW);
}
else {
for(int i=1; i<=2; i++){
digitalWrite(ledPin, HIGH);
delay(timeFlash);
digitalWrite(ledPin, LOW);
delay(timeFlash);
}
delay(200);
for(int i=1; i<=2; i++){
digitalWrite(ledPin, HIGH);
delay(timeFlash);
digitalWrite(ledPin, LOW);
delay(timeFlash);
}
delay(200);
for(int i=1; i<=3; i++){
digitalWrite(ledPin, HIGH);
delay(timeFlash);
digitalWrite(ledPin, LOW);
delay(timeFlash);
}
delay(200);
for(int i=1; i<=3; i++){
digitalWrite(ledPin, HIGH);
delay(timeFlash);
digitalWrite(ledPin, LOW);
delay(timeFlash);
}
delay(200);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////