removed
Post the formatted code you have wrote so far, in code tags.
int Lightoutput(13);
void setup() {
pinMode (Lightoutput, OUTPUT);
}
void loop() {
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalRead(7)
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(12, HIGH);
delay(100);
digitalWrite(12, LOW);
delay(100);
digitalWrite(12, HIGH);
}
Like I said its basic and im a beginner so I used this as a base. I read around that delay() is frowned upon.
How is pin 2 wired?
TheMemberFormerlyKnownAsAWOL:
How is pin 2 wired?
Just a push button
I'll try again.
How is pin 2 wired?
Where you might want to start is figuring out how to use millis(), which can be found here Using millis() for timing. A beginners guide - Introductory Tutorials - Arduino Forum.
What uController (micro controller) are you using?
Can you post a schematic?
Idahowalker:
Where you might want to start is figuring out how to use millis(), which can be found here Using millis() for timing. A beginners guide - Introductory Tutorials - Arduino Forum.What uController (micro controller) are you using?
Can you post a schematic?
I don't have a schematic. Im using an Arduino Uno and for the time being im trying to at least get the first part to blink 3 times and stay on after the 3rd blink (so just removing the digitalRead from the loop
JonathanD1:
I don't have a schematic.
So how do you know how to wire everything?
TheMemberFormerlyKnownAsAWOL:
So how do you know how to wire everything?
I don't think that'll be an issue, I know most of the basics to wire it. For now im trying to do what I reference as above. Trying to learn things slowly
JonathanD1:
I don't think that'll be an issue,
Great.
I admire your confidence.
How's it working-out?
TheMemberFormerlyKnownAsAWOL:
How's it working-out?
The only issue is how I can keep the light to stay on after the third flash. And currently im researching the millis function as it was recommended above
“knowing most of the basics” is fine, but the first thing when you actually connect bits together is a wiring diagram or schematic of stuff is wired together.
It may be in inside your head for a simple project, but we’re asking you to write/draw it out so we can see what’s in your mind.
“I don't think that'll be an issue,”, then why are you asking?
Remind us - what is connected to pin 7?
Is it important that the code in reply #2 doesn't compile?
TheMemberFormerlyKnownAsAWOL:
Remind us - what is connected to pin 7?
Is it important that the code in reply #2 doesn't compile?
Oh that was a mistake I forgot to remove. im using the built in LED just to test it out. and no right now it pin 2 doesn't matter.
void loop() {
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(200);
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(200);
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
delay(200);
digitalWrite(13, HIGH);
}
I guess what I should be asking is help in this portion. to make the light stay on after the 3rd blink
While it will do exactly what you want, you need to stop the loop() immedately after you turn i goff the LED the last time, otherwise when loop goes around, the LED will be turned off190mS late when it flashes again.
BUT this isn’t the right way to build control logic like this.
I'm losing the plot now. (Or maybe you are)
What is the problem?
The code in your last post is missing a setup function.
What is it you are trying to do?
And how is your (apparently unused) switch wired ? (I may have already mentioned this)
lastchancename:
While it will do exactly what you want, you need to stop the loop() immedately after you turn i goff the LED the last time, otherwise when loop goes around, the LED will be turned off190mS late when it flashes again.BUT this isn’t the right way to build control logic like this.
Could you point me to any reference for the correct way to build It correctly? much appreciated
without being condescending, you need to understand what you’re doing now, then with that knowledge you can take on more complex ideas like millis() and counting.
Plenty of people above have tried to steer / ask you in the right direction, but you’re still pushing the wrong direction.
Go back to reply #1, and start working through - to address what’s been asked & suggested.
JonathanD1:
The only issue is how I can keep the light to stay on after the third flash. And currently im researching the millis function as it was recommended above
One way is to use a variable that increases count with each LED blink, when the count exceeds a preset number, instead of blinking an LED, your code will now cause the led to remain light.
int NumberOfLED_Blinks = 0;
code to blink led.
Has led blinked 3 times if so enable LED till the other thing do, if not blink LED, increment NumberOfLED_Blinks. repeat till LED blinking NumberOf LED_BLinks = 3.
The other thing do sets NumberOfLED_Blinks to 0.