YourDuinoStarter Blink

From ArduinoInfo
Jump to: navigation, search


This is our version of the usual BLINK sketch everyone starts with. It has more structure and explanation and is similar to the many other example Sketches you will find here.

You can connect other output devices to Pin 13 and see them go On and Off like the built-in LED. Try these:

  • LED with a series 220 ohm resistor</span>
  • Buzzer module</span>
  • Red Laser Brick</span>

You can copy and paste the text below into a blank Arduino IDE window.

/* YourDuinoStarter Example: BLINK
 - WHAT IT DOES: Blinks the built-in LED ON and OFF
 - SEE the comments after "//" on each line below
 - Built-In LED and resistor connected to pin 13
 - V1.01 02/11/13
 Questions: */

/*-----( Import needed libraries )-----*/
//none yet
/*-----( Declare Constants and Pin Numbers )-----*/
#define led 13  // define name of pin number  NOTE: NO ";" on #define !
/*-----( Declare objects )-----*/
//none yet
/*-----( Declare Variables )-----*/
//none yet

void setup()   /****** SETUP: RUNS ONCE ******/
  pinMode(led, OUTPUT);  // initialize the digital pin as an output. 
}//--(end setup )---

void loop()   /****** LOOP: RUNS CONSTANTLY ******/
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second, watching the bright LED
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second, watch the Dark

}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/
//None yet
//*********( THE END )***********