Very new to this, noob question!

I just installed my arduino uno and started looking at the examples!
I soon realized what my first project was going to be but cannot solve it!
What i want to do it probably for most people here childsplay but for me, not so easy :~

I opened the "blink" program and soon realized i wanted to do a linear increase of the delay but cannot figure it out!
I looked at the other programs (fade amongst others) but still couldn´t do it!
Here´s my plan

void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}

void loop() {
digitalWrite(13, HIGH); // set the LED on
delay(10); // wait for a second
<--------//an icrease of the delay 10 ms for each loop until reach a delay of 1000
digitalWrite(13, LOW); // set the LED off
delay(10); // wait for a second
<--------//an icrease of the delay 10 ms for each loop until reach a delay of 1000
<--------//restart the loop with a delay of 10 when reaching 1000.
}

Thanks!

Ricard

Create a variable to define the delay value. On each pass through loop, add 10 if the value in the variable is less then 1000. Use that variable in the delay call, instead of the constant.

Could you please give me an example!
I have no more than about 2 hours of experience from this. :blush:

I have no more than about 2 hours of experience from this.

I would suggest that you google for 'C tutorial', and try and familiarise yourself with the basic concepts. It will be time well spent.

I will do that, thanks!
Just wanted do some easy examples while learning! :blush:

I looked at the other programs (fade amongst others) but still couldn´t do it!

So why not try something you can do.
Learn to take small steps.

If you insist on doing this large jump first:-
Take each one of PaulS answers and read up on it.

Create a variable to define the delay value.

Learn how to define your own variables.
delay(10) ;
will now be
delay(myNewVariable) ;

add 10 if the value

See how you can change them using the = operator

if the value in the variable is less then 1000

learn about the if operator

Thanks, working on it.
I understand the basic concept but it´s a jungle when i don´t know exactly what i´m looking for.
I also understand how bored you all must be answering questions like this one but i thougt my little project was
a "beginners project"?

I also understand how bored you all must be answering questions like this one

No it is not that at all. We are trying to help you to learn, we do not want to do it for you. If you do it yourself you will learn.

If you can't understand PaulS answer then you have not learned enough to do this project.
A good start is to read an introductory chapter or two on the basics of C programming not dive in and try and do something you have no idea about.

I don't want to deprive you of this:-

That really is a brilliant video!

Work through a number of the examples, noting the similarities and the differences.

Perhaps what you need for now can be found here:

Really, learn to 'fish' and 'eat' for life!

and may I suggest that before trying to write, use that page as your dictionary to decipher different examples. When you understand how and why they work then you will be able to write far better than those who try to start off learning by writing. It simply because those ones must unlearn the concepts they gave themselves in the rush.

Just trying to get you on the easier path....

Got a bit further with some help from a friend.
Having so much fun doing this.
This code is probably crap but it´s working. :slight_smile:

int counter = 0;

void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}

void loop()
{
while(counter <= 2000) //om mer än 1000 slutar programmet
{
digitalWrite(13, HIGH); // set the LED on
delay(counter); // wait for a second
digitalWrite(13, LOW); // set the LED off
delay(counter); // wait for a second
counter += 10;

}
}

   while(counter <= 2000)  //om mer än 1000 slutar programmet

2000 != 1000

1 second, 2 seconds, there's art in the decision...

You could replace the 10 in the counter += 10 line with a variable and the 2000 with a variable and make it count down when it reaches the top and then back up when hits zero again.. which could take a while.

Eventually you might ditch the while loop for an if since loop() itself runs over and over. Then you'll be ready to get rid of the delays and that will have you ready to approach multitasking, how to do many things "at once". At the rate you're moving you'll probably have that before Friday.

Gadjimoj,

I am relatively new also but here is what I would do...

//define your variable
int delayTime Before you" void loop()"

insert
if(delayTime >= 1000){
delayTime = 10;
}

replace delay(10); with delay(delayTime);

insert delayTime = delayTime + 10;
this will increment the delay 10 milliseconds at a time.

I hope this is a help to you have fun.

regards Jrobbins0959

Sorry, played around with the numbers and forgot to change the comment.
As you´ve already said the change is barely noticable after a few cycles since the increase in delay in relation to the delay get´s smaller as it goes.
Thanks for all your help!

You could have the change in delay increase, as a percentage instead of a constant even. There's a neat scaling trick for integers, say if you wanted to increase a number by 25% you first multiply by 5 then divide by 4. Forth has an actual such 'word' named */ that does that sequence.

GoForSmoke:
You could have the change in delay increase, as a percentage instead of a constant even. There's a neat scaling trick for integers, say if you wanted to increase a number by 25% you first multiply by 5 then divide by 4. Forth has an actual such 'word' named */ that does that sequence.

hmmm, what´s "forth"?
i tried multiplying using *= but couldn´t get it to work!?

Forth is a computer language.

Gadjimoj, Forth is another computer language and one command (called words in Forth) is */. What that does is take one integer, multiply it by another and divide by a third. The method gives the more accurate integer scaling than divide first then multiply.

Arduinos have no floating-point hardware. Using floats is way far slower than using integers, even long (32-bit) or long long (64-bit) integers.

Your sketch could also serve as a platform to display sensor readings by having them change or control... well you have more than one value affecting the led in more than one way. Maybe a simple game is possible, who knows?