Show Posts
Pages: 1 ... 4 5 [6]
76  Using Arduino / Project Guidance / Random ON OFF generator project...for LED tea candle on: November 11, 2012, 02:46:16 pm
Hi everyone!!!

I am working on creating an LED tea candle effect. I wrote this code so far, but it doesn't fade smoothly and look realistic...Its really cool on an LED, but I need help with making it fade and look like a candle. Could someone re-write this code so that it looks like a candle LED? Thanks!!! Here is the code so far:


//(I made sure that you know what each line of the functions and code is for by adding a note beside each one.)

int ledPin = 13;                  // LED connected to (digital) pin 13
long randOn = 0;                  // Initialize a variable for the ON time
long randOff = 0;                 // Initialize a variable for the OFF time
int led = 13;                     //ignore
int brightness = 0;               //ignore
int fadeAmount = 10;              //ignore


void setup()                      // run once, when the sketch starts
{
  randomSeed (analogRead (0));    // randomize
  pinMode(ledPin, OUTPUT);        // sets the digital pin as output
}

void loop()                       // run over and over again
{
  randOn = random (20, 600);    // generate ON time between x seconds (fiddle with these values to get the length of time ON)
  randOff = random (20, 600);    // generate OFF time between y seconds (fiddle with these values to get the length of time OFF)
    digitalWrite(ledPin, HIGH);   // sets the LED on
    delay(randOn);                // waits for a random time while ON
    digitalWrite(ledPin, LOW);    // sets the LED off
    delay(randOff);               // waits for a random time while OFF
      analogWrite(led, brightness);    //ignore

 
  brightness = brightness + fadeAmount;  //ignore

   
  if (brightness == 0 || brightness == 255) //ignore
    fadeAmount = -fadeAmount ;               //ignore
}
//blinks the LED randomly...can I make it look like a candle???
77  Using Arduino / Project Guidance / Infrared Interferance on: November 11, 2012, 02:41:44 pm
Hi everyone!

I really want to do a project on interfering with a remote control for a TV so no one can change the channel. I have already built one with a TL2082 chip and a 555 timer, but I really want to build one with an arduino. Most TV infrared remotes travel at about 38kz, so if someone could write a simple code for an infrared LED to interfere with the remote would be great...Thanks!!!!
78  Using Arduino / Sensors / Infrared Interferance on: November 11, 2012, 02:38:06 pm
Hi everyone.

I really want to do a project that interferes with the remote control of the TV....Is there any code that might be able to work? I think that the frequency of most TV infrared remotes is 38kz.....If I write a code that oscillates an infrared LED at about that freq, then it might work...Can someone please write a code? Thanks!!! smiley-lol
79  Using Arduino / Programming Questions / Re: How Can I Force A Loop Restart on: November 11, 2012, 11:49:15 am
Maybe this will help: Its a random ON OFF generator


Code:
int ledPin = 13;                  // LED connected to (digital) pin 13
long randOn = 0;                  // Initialize a variable for the ON time
long randOff = 0;                 // Initialize a variable for the OFF time
int led = 13;                     //ignore
int brightness = 0;               //ignore
int fadeAmount = 10;              //ignore


void setup()                      // run once, when the sketch starts
{
  randomSeed (analogRead (0));    // randomize
  pinMode(ledPin, OUTPUT);        // sets the digital pin as output
}

void loop()                       // run over and over again
{
  randOn = random (20, 600);    // generate ON time between x seconds (fiddle with these values to get the length of time ON)
  randOff = random (20, 600);    // generate OFF time between y seconds (fiddle with these values to get the length of time OFF)
    digitalWrite(ledPin, HIGH);   // sets the LED on
    delay(randOn);                // waits for a random time while ON
    digitalWrite(ledPin, LOW);    // sets the LED off
    delay(randOff);               // waits for a random time while OFF
      analogWrite(led, brightness);    //ignore

  
  brightness = brightness + fadeAmount;  //ignore

  
  if (brightness == 0 || brightness == 255) //ignore
    fadeAmount = -fadeAmount ;               //ignore
}


Moderator edit: [code] [/code] tags added.
Pages: 1 ... 4 5 [6]