Arduino101 Blink

From Twin Cities Maker wiki
Jump to: navigation, search

The “Hello World” of Arduino-dom. Yes, this is (almost) the same as the “Blink” example sketch included with the Arduino environment. In class we have students type it in themselves, because we think that makes it more sticky in your brain.

Important Note: In the Real World, there should be a resistor either right before or right after the LED. This is to limit the amount of current going through the LED – they are hungry, and like to gorge on current until they burn out. The Arduino can only source about 40mA of current, so you can get away with no resistor, assuming you have the parts kit from class. When in doubt, put a 220 ohm resistor (Red-Red-Brown) in line with the LED.

Breadboard layout

Blink bb.png

Code

void setup() {
  // put your setup code here, to run once:
 
  pinMode(3, OUTPUT);
 
}
 
void loop() {
  // put your main code here, to run repeatedly: 
 
  digitalWrite(3, HIGH);
  delay(1000);
  digitalWrite(3, LOW);
  delay(1000);
}