//------------------------------------------------------ // Example of a Custom Function (we'll call "blinkLED") // - Setup: // Wire an LED from pin 7 thru a resistor to GND //------------------------------------------------------ int ledPin = 7; void setup() { pinMode(ledPin, OUTPUT); } void loop() { blinkLED(5, 100); //- 5 times at 100 milliseconds blinkLED(3, 600); //- 3 times at 600 milliseconds } //--- This is the custom function: void blinkLED(int times, int delayTime) { for(int i = 0; i < times; i++) { digitalWrite(ledPin, HIGH); // blink LED quickly delay(delayTime); // (100 milliseconds) digitalWrite(ledPin, LOW); delay(delayTime); } //-- (end of for() loop) } //-- (end of function definition) |