The following is a section of code from the BlinkWithoutDelay example:
void loop()
{
// here is where you would put code that needs to be running all the time.
// check to see if it is time to blink the LED; that is, if the
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
unsigned long currentMillis = millis();
if(currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}
This was posted using php syntax coloring by using:
[table][td][php]your code[/php][/td][/table]
Without the white background:
[php]your code[/php]
Certain characters (in comments) get converted to the HTML char code (i.e. '), however I think the overall result is much more readable.
[php]void loop()
{
// here is where you would put code that needs to be running all the time.
// check to see if it is time to blink the LED; that is, if the
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
unsigned long currentMillis = millis();
if(currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}[/php]
Just thought I'd give it a try without the white box
[php]void loop()
{
// here is where you would put code that needs to be running all the time.
// check to see if it is time to blink the LED; that is, if the
// difference between the current time and last time you blinked
// the LED is bigger than the interval at which you want to
// blink the LED.
unsigned long currentMillis = millis();
if(currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}[/php]
looks pretty good either way I think. For large code snippets the normal tag might be better because that will (when it's fixed) give scroll bars.
It seems that SMF Syntax Highlighter or something similar is already implemented in this forum. The code tag can take a parameter without complaining, so if we use:
[code=Arduino]//your code[/code]
we get the parameter displayed in the code box title:
//your code
I would like to propose to the forum administrators that syntax coloring for Arduino be added to the necessary translation file(s) on the server. I think it would be an awesome feature to have this as default. Then after using code tags as normal, a code box would be created having code colored like this:
If it's in quote tags it's a proportional font and some combinations are treated as bb codes, for example
for (int b = 0; b < 5; b++)
array[b] = b;
func(8);
for (int b = 0; b < 5; b++)
array = b; func(8);[/quote] Yes Robin I think it's essential that the edit timeout feature is removed. EDIT (severel hours later): Looks like it has. ______ Rob
Second time today - I just wanted to comment of this thread so I could keep an eye on it, (via my posts) seeing as I never get any post or message notifications anymore 8)