Difference between revisions of "Blink LED"

From SainSmart Wiki
Jump to: navigation, search
(Created page with "Small LED lamp experiment is the basis of comparison of the experimental one, this time we use the motherboard comes with 13 feet of LED lights to complete the experiment, the...")
 
 
Line 7: Line 7:
 
=== Example code: ===
 
=== Example code: ===
  
  int ledPin = 13; //define pin 13
+
  int ledPin = 13;
  void setup()
+
  void setup()
 
+
  {
   pinMode(ledPin, OUTPUT);//define interface is output
+
   pinMode (ledPin, output);
  }
+
}
  void loop()
+
  void loop()
 
+
  {
   digitalWrite(ledPin, HIGH); //light up led lamp
+
   digitalWrite(ledPin, HIGH);
   delay(1000); //delay 1s
+
   delay(1000);
   digitalWrite(ledPin, LOW); //go out led lamp
+
   digitalWrite(ledPin, LOW);
   delay(1000); // delay 1s
+
   delay(1000);
  }
+
}
  
 
After downloading the program, you can see our 13-foot LED lights flashing, so that our small lights flicker experiment is complete.
 
After downloading the program, you can see our 13-foot LED lights flashing, so that our small lights flicker experiment is complete.

Latest revision as of 07:47, 21 June 2013

Small LED lamp experiment is the basis of comparison of the experimental one, this time we use the motherboard comes with 13 feet of LED lights to complete the experiment, the experimental equipment we need is the Arduino which each experiment must have and USB download cable.

Next we connect small lamp in accordance with the following experimental schematic physical map.

Accordance with the good circuit after the link above figure, you can start writing programs, and we let the small LED lights flashing. Lighting on for one second and off for one second. This program is very simple. This is Arduino own routines Blink.

Example code:

int ledPin = 13;
void setup()
{
 pinMode (ledPin, output);
}
void loop()
{
 digitalWrite(ledPin, HIGH);
 delay(1000);
 digitalWrite(ledPin, LOW);
 delay(1000);
}

After downloading the program, you can see our 13-foot LED lights flashing, so that our small lights flicker experiment is complete.