Go Down

Topic: fade on then sty on (Read 280 times) previous topic - next topic

kamz007

hi iam new to Arduino.

I have got my my Arduino to blink fade. but I would like to fade slowly on then stay on.

i would be grateful if someo ne could help me getting the code for this. i haave searched all over the net and forums. and havent found any info regarding  this.

thanks in adavance for any help given


Delta_G

This isn't a free code writing service.  Show your best effort and we can help you learn what you did wrong, or go to the Gigs and Collaborations sections and offer to pay someone to write it for you. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

kamz007

hi then code I have managed to do is:

int value ;
int ledpin = 9;                           // light connected to digital pin 9
long time=0;

int periode = 20000;
int displace = 0;

void setup()
{
  Serial.begin(57600);

}
void loop()
{
  static boolean already_done  = false;
  if (!already_done)
  {
    time = millis();
    value = 128+127*cos(2*PI/periode*(displace-time));
    Serial.println(value);
    analogWrite(ledpin, 255-value);      // sets the value (range from 0 to 255)
    already_done = (value <= 1);
  }
}

its roughly what I want but I wanted to see if I can get it to glow start up then dim then start up then stay on. thanks

david_prentice

Go on.  It is not Rocket Science.
Code: [Select]

const int ledpin = 9;

void setup(void)
{
    byte val;
    pinMode(ledpin, OUTPUT);
    pinMode(8, OUTPUT);
    for (val = 0; val < 255; val++) {
        analogWrite(ledpin, val);
        delay(50);
    }
    for (val = 255; val > 0; --val) {
        analogWrite(ledpin, val);
        delay(50);
    }
    for (val = 0; val < 255; val++) {
        analogWrite(ledpin, val);
        delay(50);
    }
}

void loop(void)
{

}

Untested.

David.

kamz007

ha ha
for me it is as I am learning the codes.

thanks for your help

i wanted a glow up without delay and blink then stay on.. like what I had before but without delay.
I am planning to use a sd card.

both start at the same time

last question I have prewired 5v leds..  how many can I put on one pin..as I am having trouble making a code with more than one same kind of code


thanks again for your help :)

Delta_G

#5
Jun 07, 2018, 08:14 pm Last Edit: Jun 07, 2018, 08:14 pm by Delta_G
Is the shift key on your keyboard broken?   if you really want good help, try to look like you care a little and are willing to put in at least a modicum of effort.  If you can't even write half-ass right normal things then most folks are going to assume you could never handle code.  The compiler is far more strict about grammar than even the meanest old English teacher. 

Not trying to not-pick.  Just trying to help you get help and not look dumb. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

INTP

SD card for what? What do you mean pre-wired? No such thing as a 5V LED. Maybe you mean LEDs that you paid too much for with resistors already soldered. You can only do 1 per pin, if that's the case. What are your motivations for not using delay? Have you put any effort into learning how to use millis? What do you mean 'both start at the same time'?

Help you get is only going to be as good as the detail you give and the effort you put into helping yourself.

kamz007

I mean pre wired 5 volts leds.
And no I didn't pay to much.

I was asking how many leds, can put on one
Pin. As I can not work out how to program 2 pins on one program.

It was only a query.

And regarding what I was asking before.
Was I wanted to make the led fade on then blink then stay on.

I am half way there.

Delta_G

As I can not work out how to program 2 pins on one program.
The same way you do for one pin.  You just write a line of code to analogWrite to that pin number instead. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

kamz007

Oh ok.
Will try that out.
Thanks for your help

Go Up