Simple RGB LED fading without using analogWrite


hello,

i trying rgb fade going attiny85. problem every fading function have found online far has used analogwrite, , attiny85 has 2 pwm pins: not enough r, g , b.

i trying implement using if statements, proving quite difficult. trying method work 1 color, believe extended several once working. included picture of board being used.

this have far:
code: [select]
void fade()
{
  for(byte i=1; i<100; i++)
  {
    greenbrightness0 = greenbrightness0 + greenfaderate; //updates brightness 1/100th increment
    byte greenon  = greenbrightness0 * .390625; //wierd number factor go 256 100
    byte greenoff =  100 - greenon;
    byte = 0;
    boolean d = false; //to ensure if-loop not entered twice in row
    while(a < 100)
    {
      greentime0 = micros(); //what time it, mr. wolf?
      if(d == false && (greentime0 > greentime3 + greenon)) //greentime3 = 0
      {
        digitalwrite(greenpin, high);
        greentime2 = greentime0; //records time when greenpin went high
        d = true;
      }
      greentime1 = micros(); //what time it, mr. wolf?
      if(d == true && (greentime1 > greentime2 + greenoff))
      {
        digitalwrite(greenpin, low);
        greentime3 = greentime1; //records time when greenpin went low
        d = false;
        a++; //increments while loop
      }
    }
  }
}


i hope makes sense, , posting in correct part of forum.
thanks!

quote
i hope makes sense, , posting in correct part of forum.

it if knew problem was.


Arduino Forum > Using Arduino > Programming Questions > Simple RGB LED fading without using analogWrite


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support