LED am Arduino Uno: Unterschied zwischen den Versionen

Aus eLAB Wiki
Wechseln zu: Navigation, Suche
K
Zeile 1: Zeile 1:
== Anschluss des HC-SR04 an den Arduino ==
+
== Anschluss einer LED an den Arduino ==
  
zum Anschluss einer [[LED_Leuchtdiode|LED]] an ein Arduino Board wird ein Digital Ausgang benötigt. Auf einen Vorwiderstand kann in diesem besonderen Beispiel verzichtet werden. An Pin 13 ist der Vorwiderstand bereits auf dem Arduino Board vorhanden.
+
Zum Anschluss einer [[LED_Leuchtdiode|LED]] an ein Arduino Board wird ein Digital Ausgang und ein Widerstand von 220 Ohm benötigt.  
  
 
[[File:LED-Arduino_wiring.png|600px|LED Verdrahtung]]
 
[[File:LED-Arduino_wiring.png|600px|LED Verdrahtung]]
Zeile 13: Zeile 13:
 
/*
 
/*
 
   Blink
 
   Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
 
  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
 
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
 
  the correct LED pin independent of which board is used.
 
  If you want to know what pin the on-board LED is connected to on your Arduino model, check
 
  the Technical Specs of your board  at https://www.arduino.cc/en/Main/Products
 
 
 
  This example code is in the public domain.
 
 
  modified 8 May 2014
 
  by Scott Fitzgerald
 
 
    
 
    
   modified 2 Sep 2016
+
   Schaltet eine LED im Rythmus von einer Sekunde an und aus
  by Arturo Guadalupi
 
 
    
 
    
   modified 8 Sep 2016
+
   Dieses Beispiel aus dem Fritzing Creator Kit: www.fritzing.org/creator-kit.
  by Colby Newman
 
 
*/
 
*/
  
 +
int led = 13;                  // ganzzahlige Variable led wird deklariert
  
// the setup function runs once when you press reset or power the board
+
void setup() {                 // die setup()-Methode wird einmal ausgeführt
void setup() {
+
   pinMode(led, OUTPUT);    
  // initialize digital pin LED_BUILTIN as an output.
 
   pinMode(LED_BUILTIN, OUTPUT);
 
 
}
 
}
  
// the loop function runs over and over again forever
+
void loop() {                  // die loop()-Methode wird immer wiederholt
void loop() {
+
   digitalWrite(led, HIGH);     // schaltet die LED ein
   digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
+
   delay(1000);                 // hält das Programm für 1000 Millisekunden an
   delay(1000);                       // wait for a second
+
   digitalWrite(led, LOW);       // schaltet die LED ab
   digitalWrite(LED_BUILTIN, LOW);   // turn the LED off by making the voltage LOW
+
   delay(1000);                 // hält das Programm für 1000 Millisekunden an
   delay(1000);                       // wait for a second
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Version vom 19. Februar 2018, 23:15 Uhr

Anschluss einer LED an den Arduino

Zum Anschluss einer LED an ein Arduino Board wird ein Digital Ausgang und ein Widerstand von 220 Ohm benötigt.

LED Verdrahtung

LED Schaltplan


Programm für den Arduino

/*
  Blink
  
  Schaltet eine LED im Rythmus von einer Sekunde an und aus
  
  Dieses Beispiel aus dem Fritzing Creator Kit: www.fritzing.org/creator-kit.
*/

int led = 13;                   // ganzzahlige Variable led wird deklariert

void setup() {                  // die setup()-Methode wird einmal ausgeführt
  pinMode(led, OUTPUT);     
}

void loop() {                   // die loop()-Methode wird immer wiederholt
  digitalWrite(led, HIGH);      // schaltet die LED ein 
  delay(1000);                  // hält das Programm für 1000 Millisekunden an
  digitalWrite(led, LOW);       // schaltet die LED ab
  delay(1000);                  // hält das Programm für 1000 Millisekunden an
}