Changes

Jump to: navigation, search

Week 2 Lab

466 bytes added, 16:10, 7 April 2009
Some Programming
* The <code>digitalWrite(ledPin, HIGH)</code> turns on the LED
* <code>digitalWrite(ledPin, LOW)</code> turns off the LED.
* What is this actually doing? The <code>HIGH</code> is setting that output pin to High, 1, True, +5V. * similarity, the <code>LOW</code> is setting that output pin, to Low, 0, False, 0V or GND.
* This is where your programmable, internal world of the microcontroller is interfacing with the hardware, LED world of intro to electronics.
* We needed to do some setup first <code>pinMode(ledPin, OUTPUT)</code>
* and then it is a matter of <code>digitalWrite</code> calls.
* Similarly, in the digital_in example above, we do some setup <code>
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare pushbutton as input
</code>
* And then we read inputs and make outputs with <code>digitalRead</code> and <code>digitalWrite</code> calls.
*
* So what can we change?
* You could insert your own code, for instance
* to get a "long-short-long-short" blinking.
** Try this out.
* As you add more complicated behavior here, things are going to get ridiculous very soon, you will have tons of special cases, lines and lines of code. There are more efficient ways to do this...
* What are more efficient ways to do this, use For loops or arrays.

Navigation menu