How do i call this routine?

searched but cannot find what i am doing wrong?

I am new to Arduino having used Basic before. I wish to use the routine do_this

I like to have things in their own routines so thought i would try something simple first, but cannot get this right?

i get "error 'ledPin' was not declared in this scope"

//-----------------------------------------------------------------------

void setup()   {  

  do_this();

  pinMode(ledPin, OUTPUT);     //error 'ledPin' was not declared in this scope
}

//-----------------------------------------------------------------------

void loop()                        
{
  // Do something
}

//----------------------------------------------------------------------

void do_this()
{
  const int ledPin =  13;    // LED connected to digital pin 13
}

//-----------------------------------------------------------------------

I am sure this is very simple but need a little help?

Regards

Gary

You have the led = 13 line inside of a routine, that makes it a LOCAL variable and not a GLOBAL variable. Also, C requires that everything be defined BEFORE you use it.

Understand that the setup code gets called ONCE, and loop gets called forever.

Your code should look like this

//-----------------------------------------------------------------------

  const int ledPin =  13;    // LED connected to digital pin 13


void setup()   {  

  do_this();

  pinMode(ledPin, OUTPUT);     //error 'ledPin' was not declared in this scope
}

//-----------------------------------------------------------------------

void loop()                       
{
  // Do something
}

//----------------------------------------------------------------------

void do_this()
{
}

//-----------------------------------------------------------------------