I want to make a delay using for loop. The following two attempts did not work. I use Serial.print on small loop and they are increment correctly. When installed in my program they just don't work. The on period is very short and cannot be adjusted. Full program follows.
Thank you for your time.
smd61
smd61@sdavidson.net
// this does not work.
for (int i = 0; i < 1000; i++)
{ int l = 1000/i; //make work
for( int j = 0; j < 1000; j++)
{ int k = 1000/j; // make work
}
}
// this did not work either.
/* for (int i = 0; i <1000; i++)
for( int j = 0; j<1000; j++)
*/
---------------------
Full program:
/*
Blink
The basic Energia example.
Turns on an LED on for one second, then off for one second, repeatedly.
Change the LED define to blink other LEDs.
Hardware Required:
* LaunchPad with an LED
This example code is in the public domain.
*/
// most launchpads have a red LED
#define LED RED_LED
//see pins_energia.h for more LED definitions
//#define LED GREEN_LED
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(LED, OUTPUT);
Serial.begin(9600);
Serial.println("-------------"); // show start of program
}
// the loop routine runs over and over again forever:
void loop() {
Serial.print("_____"); // Show start of blink cycle
digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
Serial.println("high");
// this does not work. // delay for 1 sec
for (int i = 0; i < 1000; i++)
{ int l = 1000/i; //make work
for( int j = 0; j < 1000; j++)
{ int k = 1000/j; // make work
}
}
// this did not work either. // delay for 1 sec
/* for (int i = 0; i <1000; i++)
for( int j = 0; j<1000; j++)
*/
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
Serial.println("low");
delay(1000); // wait for a second
}