I have been trying to teach myself programming and really making use of the forums on here. I'm currently working with a code that will have an LED flash for about 1 sec after a button push/signal but no luck. The only code i have worked is using delay...but I am really trying to avoid that. here's what the code looks like:
//////(with delay)
void loop() {
Serial.println("Press 1 to turn Arduino pin 13 LED ON or 0 to turn it OFF:");
while (!Serial.available()); // stay here so long as COM port is empty
INBYTE = Serial.read(); // read next available byte
if( INBYTE == '1' ) {digitalWrite(LED, HIGH); // if it's a 1 (one) turn LED on
}
delay(500);
{
digitalWrite(LED, LOW);
}
}
/////////// Here's the other code i would love to get working(without delay)
You should pay attention to conventions, too. All upper case name are for constants. Constants do not appear on the left of an equal sign.
For the record, LEDs attached to Arduino pins do not flash. The pins are turned on and off. Using proper terminology to describe your issue will go a long way towards getting answers that you can use.
And yes, I should pay attention to where I place my brackets and convention. It's my 2nd month doing this. Any suggestions on how i can be better at coding?
One of the simplest tips I have is, if you start to write a control structure ("if", "for", "while") or a function definition, always write the opening and closing braces for that structure at the correct indentation level.
AWOL:
One of the simplest tips I have is, if you start to write a control structure ("if", "for", "while") or a function definition, always write the opening and closing braces for that structure at the correct indentation level.