websitetemplate.org

Hjem > Arduino Duemilanove > RGB Led

RGB Led

Dimsen er lyskilden fra en scanner.


3 stk. 330 ohm + en stump ledning.

Så er der klar til at lege med lys kunst ;-)

/*
  Dimmer   RGB
*/
                                    // RGB Led
                                    // Fælles +5 volt
const int RledPin =  9;      // Led Rød  kanal Fælles +5 volt
const int GledPin = 10;      // Led Grøn kanal
const int BledPin = 11;      // Led Blå  kanal

int RedR  = 254 ;
int GronR = 254;
int BlaaR = 254;

void setup()
{
  // initialize the ledPin as an output:
  analogWrite(RledPin, 255);
  analogWrite(GledPin, 255);
  analogWrite(BledPin, 255);

void loop() {

  for ( int Red = 250; Red > 100 ; Red-=10 ){
    analogWrite(RledPin, Red); delay( 50 ); }
    analogWrite(RledPin, 0); delay( 1000 );
  for ( int Red = 100; Red < 250 ; Red+=10 ){
    analogWrite(RledPin, Red); delay( 50 ); }
  analogWrite(RledPin, 255);

  for ( int Gron = 255; Gron > 100 ; Gron-=10 ){
    analogWrite(GledPin, Gron); delay( 50 ); }
    analogWrite(GledPin, 0); delay( 1000 );
  for ( int Gron = 100; Gron < 250 ; Gron+=10 ){
    analogWrite(GledPin, Gron); delay( 50 ); }
  analogWrite(GledPin, 255);

  for ( int Blaa = 255; Blaa > 100 ; Blaa-=10 ){
    analogWrite(BledPin, Blaa); delay( 50 ); }
    analogWrite(BledPin, 0); delay( 1000 );
  for ( int Blaa = 100; Blaa < 250 ; Blaa+=10 ){
    analogWrite(BledPin, Blaa); delay( 50 ); }
  analogWrite(BledPin, 255);
   
  for ( int Red = 250; Red > 100 ; Red-=10 ){
    analogWrite(GledPin, Red); analogWrite(BledPin, Red); delay( 50 ); }
  analogWrite(GledPin, 0); analogWrite(BledPin, 0); delay( 1000 );
  for ( int Red = 100; Red < 250 ; Red+=10 ){
    analogWrite(GledPin, Red); analogWrite(BledPin, Red); delay( 50 ); }
  analogWrite(GledPin, 255); analogWrite(BledPin, 255);

  for ( int Red = 250; Red > 100 ; Red-=10 ){
    analogWrite(RledPin, Red); analogWrite(BledPin, Red); delay( 50 ); }
  analogWrite(RledPin, 0); analogWrite(BledPin, 0); delay( 1000 );
  for ( int Red = 100; Red < 250 ; Red+=10 ){
    analogWrite(RledPin, Red); analogWrite(BledPin, Red); delay( 50 ); }
  analogWrite(RledPin, 255); analogWrite(BledPin, 255);
 
  for ( int Red = 250; Red > 100 ; Red-=10 ){
    analogWrite(RledPin, Red); analogWrite(GledPin, Red); delay( 50 ); }
  analogWrite(RledPin, 0); analogWrite(GledPin, 0); delay( 1000 );
  for ( int Red = 100; Red < 250 ; Red+=10 ){
    analogWrite(RledPin, Red); analogWrite(GledPin, Red); delay( 50 ); }
  analogWrite(RledPin, 255); analogWrite(GledPin, 255);

  for ( int Red = 250; Red > 100 ; Red-=10 ){
    analogWrite(GledPin, Red); analogWrite(BledPin, Red); analogWrite(RledPin, Red); delay( 50 ); }
  analogWrite(GledPin, 0); analogWrite(BledPin, 0);  analogWrite(RledPin, 0); delay( 1000 );
  for ( int Red = 100; Red < 250 ; Red+=10 ){
    analogWrite(GledPin, Red); analogWrite(BledPin, Red); analogWrite(RledPin, Red);  delay( 50 ); }
  analogWrite(GledPin, 255); analogWrite(BledPin, 255);
 
  }






Powered By CMSimple.dk - Design By OZ5HZ Finn Johansen