Difference between revisions of "Week 3 Lab"

From Robert-Depot
Jump to: navigation, search
(LED Dimming)
Line 8: Line 8:
 
== Analog Output ==
 
== Analog Output ==
 
=== LED Dimming ===
 
=== LED Dimming ===
 +
*File->Sketchbook->Examples->Analog->Fading
 +
<code>
 +
void loop()
 +
{
 +
  for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)
 +
  {
 +
    analogWrite(ledpin, value);          // sets the value (range from 0 to 255)
 +
    delay(30);                            // waits for 30 milli seconds to see the dimming effect
 +
  }
 +
  for(value = 255; value >=0; value-=5)  // fade out (from max to min)
 +
  {
 +
    analogWrite(ledpin, value);
 +
    delay(30);
 +
  } 
 +
}
 +
</code>
 
*lights, fading
 
*lights, fading
 
<youtube v="62gWVWCyw_w" loop="true"/>
 
<youtube v="62gWVWCyw_w" loop="true"/>

Revision as of 21:23, 12 April 2009

from Electronic Technologies for Art

Analog Input

  • Potentiometer
  • photo-resistor
  • strain gauge

Analog Output

LED Dimming

  • File->Sketchbook->Examples->Analog->Fading

void loop() {

 for(value = 0 ; value <= 255; value+=5) // fade in (from min to max) 
 { 
   analogWrite(ledpin, value);           // sets the value (range from 0 to 255) 
   delay(30);                            // waits for 30 milli seconds to see the dimming effect 
 } 
 for(value = 255; value >=0; value-=5)   // fade out (from max to min) 
 { 
   analogWrite(ledpin, value); 
   delay(30); 
 }  

}

  • lights, fading

<youtube v="62gWVWCyw_w" loop="true"/>

Motor Speed Control

  • Basic motor control (DC motors) see week 5


Sound, Tone Generation

  • sounds, tone generation