IFD:PhysicalComp2011/code: Difference between revisions

From Medien Wiki
mNo edit summary
Line 572: Line 572:


== 21.11.2011 Arduino workshop sketches ==
== 21.11.2011 Arduino workshop sketches ==
=== I Blinking LED ===
<source lang="java">
/* BLINKING LED
*
* Demonstrates how to make a LED connected to digital pin 4
* blink in an interval of 1 second.
*
* You could also use the internal LED on pin 13. This
* LED is mounted onto the board with a resistor in between,
* so whenn connecting a LED to pin 13 we don't need an extra
* resistor.
*/
// specifiy the pin for our LED
int ledPin = 4;
void setup(){
  // configure the pin of the LED as an output
  pinMode(ledPin, OUTPUT);
}
void loop(){
 
  // set the LED pin to HIGH (+5 Volts)
  digitalWrite(ledPin, HIGH);
  // wait for 1000 milliseconds = 1 second
  delay(1000);
  // set the LED pin to LOW (0 Volts)
  digitalWrite(ledPin, LOW);
  // again wait 1 second
  delay(1000);
}
</source>
<br /><br />


[[Category:Physical Computing]]
[[Category:Physical Computing]]
[[Category:Frederic Gmeiner]]
[[Category:Frederic Gmeiner]]
[[Category:WS11/12]]
[[Category:WS11/12]]