Senior Project - PIR senors with LED's sequence

As a Senior project I am working on a project for a local company that specializes in helping people who are mentally challenged, or people who have no work skills. The project is kicking my butt because this is my first time working with Arduino, and i am learning everything as I go. This project is a trainer system so the employees can get a feel for what they are doing, and help gain an understanding of the concept of getting all the tools in order.

Here is the Scenario-

I have 10 cubby holes filled with small tools (tiny wrenches, sockets, etc) the people at these stations must take them out put them in a bag or box. Each cubby hole has a different size tool. Each cubby hole has its own Parallax PIR Sensor, and a LEDon the front of each cubby hole. I will also have a buzzer, to tell the employee that you did something wrong.

Here is the sequence-
when you turn on the trainer (after waiting for the sensors to calibrate) the LED on the first cubby hole turns on.
when you stick your hand in the first box to grab a part, the LED on the first box is turned off and the LED on the second box is turned on.
You stick your hand in the second box to grab a part, and the LED on the second box is turned off and the light on the third box is turned on... etc. This cycle repeats until you pull the plug.

Each LED is a guide to tell you which box to pull a part out of.

I have a couple of problems-

  1. I am not the greatest at programming
  2. The programing I have done im not sure will work

My Questions and Concerns

  1. Will the program that I have attached (minus the buzzer) work like I envisioned?

  2. How do I add a buzzer into the program so that when you stick you hand into a box that does not have a light on, the buzzer goes off telling you it is wrong, until you stick your hand into a box with the light on?

  3. Do I need a resistor for each LED if the LED's are 3.5v and the output on my Arduino is 3.5?

Here is my program so far:

int LED1pin=11;                              //LED 1 on output pin 11
int LED2pin=12;                              //LED 2 on output pin 12
int LED3pin=13;                              //LED 3 on output pin 13
int LED4pin=14;                              //LED 4 on output pin 14
int LED5pin=15;                              //LED 5 on output pin 15
int LED6pin=16;                              //LED 1 on output pin 16
int LED7pin=17;                              //LED 2 on output pin 17
int LED8pin=18;                              //LED 3 on output pin 18
int LED9pin=19;                              //LED 4 on output pin 19
int LED10pin=20;                        //LED 5 on output pin 20

int LEDgpin=21;                                 //Green LED on output pin 21

int PIR1pin=1;                                //PIR 1 on input pin 1
int PIR2pin=2;                              //PIR 2 on input pin 2
int PIR3pin=3;                              //PIR 3 on input pin 3
int PIR4pin=4;                              //PIR 4 on input pin 4
int PIR5pin=5;                              //PIR 5 on input pin 5
int PIR6pin=6;                              //PIR 1 on input pin 6
int PIR7pin=7;                              //PIR 2 on input pin 7
int PIR8pin=8;                              //PIR 3 on input pin 8
int PIR9pin=9;                              //PIR 4 on input pin 9
int PIR10pin=10;                          //PIR 5 on input pin 10

int buzzpin=22;                                 //Buzzer on output pin 1

void setup()                              //Sets up arduino inputs and outputs
{
  pinMode(LED1pin, OUTPUT);                  //Sets LED 1 as an output
  pinMode(LED2pin, OUTPUT);                  //Sets LED 2 as an output
  pinMode(LED3pin, OUTPUT);                  //Sets LED 3 as an output
  pinMode(LED4pin, OUTPUT);                  //Sets LED 4 as an output 
  pinMode(LED5pin, OUTPUT);                  //Sets LED 5 as an output
  pinMode(LED6pin, OUTPUT);                  //Sets LED 6 as an output
  pinMode(LED7pin, OUTPUT);                  //Sets LED 7 as an output
  pinMode(LED8pin, OUTPUT);                  //Sets LED 8 as an output
  pinMode(LED9pin, OUTPUT);                  //Sets LED 9 as an output 
  pinMode(LED10pin, OUTPUT);                  //Sets LED 10 as an output
  
  pinMode(LEDgpin, OUTPUT);                     //Sets green LED as an output
  
  pinMode(buzzpin, OUTPUT);                     //Sets buzzer as an output
  
  pinMode(PIR1pin, INPUT);                  //Sets PIR 1 as an input
  pinMode(PIR2pin, INPUT);                  //Sets PIR 2 as an input
  pinMode(PIR3pin, INPUT);                  //Sets PIR 3 as an input
  pinMode(PIR4pin, INPUT);                  //Sets PIR 4 as an input
  pinMode(PIR5pin, INPUT);                  //Sets PIR 5 as an input
  pinMode(PIR6pin, INPUT);                  //Sets PIR 6 as an input
  pinMode(PIR7pin, INPUT);                  //Sets PIR 7 as an input
  pinMode(PIR8pin, INPUT);                  //Sets PIR 8 as an input
  pinMode(PIR9pin, INPUT);                  //Sets PIR 9 as an input
  pinMode(PIR10pin, INPUT);                  //Sets PIR 10 as an input
}

void loop()                              //runs program continuously
{
 digitalWrite(LED1pin, HIGH);                  //turns on LED 1
 digitalWrite(LEDgpin, HIGH);                   //Turns on Green indicator light to tell the trainer is working
  {
   do                                    //check if PIR sensor is high, but if its low then
    {                                    //it keeps checking until its high
     if(digitalRead(PIR1pin) == HIGH)              //Checks if PIR sensor is High
      {
       digitalWrite(LED1pin, LOW);            //turns off LED 1
       digitalWrite(LED2pin, HIGH);            //turns on LED 2
      }
   }
   while (digitalRead(PIR1pin) == LOW);            //if PIR is low, then it repeats this specific sequence

   do                                    //check if PIR sensor is high, but if its low then
    {                                    //it keeps checking until its high
     if(digitalRead(PIR2pin) == HIGH)              //Checks if PIR sensor is High
      {
         digitalWrite(LED2pin, LOW);            //turns off LED 2
       digitalWrite(LED3pin, HIGH);            //turns on LED 3
      }
    }
   while (digitalRead(PIR2pin) == LOW);              //if PIR is low, then it repeats this specific sequence

   do                                    //check if PIR sensor is high, but if its low then
    {                                      //it keeps checking until its high
     if(digitalRead(PIR3pin) == LOW)                   //Checks if PIR sensor is High
      {
       digitalWrite(LED3pin, LOW);            //turns off LED 3
       digitalWrite(LED4pin, HIGH);            //turns on LED 4
      }
    }
   while (digitalRead(PIR3pin) == LOW);              //if PIR is low, then it repeats this specific sequence

   do                                      //check if PIR sensor is high, but if its low then
    {                                    //it keeps checking until its high
     if(digitalRead(PIR4pin) == HIGH)              //Checks if PIR sensor is High
      {
       digitalWrite(LED4pin, LOW);            //turns off LED 4
       digitalWrite(LED5pin, HIGH);            //turns on LED 5
      }
    }
   while (digitalRead(PIR4pin) == LOW);            //if PIR is low, then it repeats this specific sequence

   do                                    //check if PIR sensor is high, but if its low then
    {                                    //it keeps checking until its high
     if(digitalRead(PIR5pin) == HIGH)              //Checks if PIR sensor is High
      {
       digitalWrite(LED5pin, LOW);            //turns off LED 5
       digitalWrite(LED6pin, HIGH);            //turns on LED 6
      }
    }
   while (digitalRead(PIR5pin) == LOW);            //if PIR is low, then it repeats this specific sequence

   do                                    //check if PIR sensor is high, but if its low then
    {                                    //it keeps checking until its high
     if(digitalRead(PIR6pin) == HIGH)            //Checks if PIR sensor is High
      {
       digitalWrite(LED6pin, LOW);            //turns off LED 6
       digitalWrite(LED7pin, HIGH);            //turns on LED 7
      }
    }
   while (digitalRead(PIR6pin) == LOW);              //if PIR is low, then it repeats this specific sequence

   do                                    //check if PIR sensor is high, but if its low then
    {                                    //it keeps checking until its high
     if(digitalRead(PIR7pin) == HIGH)           //Checks if PIR sensor is High
      {
       digitalWrite(LED7pin, LOW);            //turns off LED 7
       digitalWrite(LED8pin, HIGH);            //turns on LED 8
      }
    }
   while (digitalRead(PIR7pin) == LOW);              //if PIR is low, then it repeats this specific sequence

   do                                    //check if PIR sensor is high, but if its low then
    {                                    //it keeps checking until its high
     if(digitalRead(PIR8pin) == HIGH)                  //Checks if PIR sensor is High
      {
       digitalWrite(LED8pin, LOW);            //turns off LED 8
       digitalWrite(LED9pin, HIGH);            //turns on LED 9
      }
    }
   while (digitalRead(PIR8pin) == LOW);            //if PIR is low, then it repeats this specific sequence
  
   do                                    //check if PIR sensor is high, but if its low then
    {                                    //it keeps checking until its high
     if(digitalRead(PIR9pin) == HIGH)              //Checks if PIR sensor is High
      {
       digitalWrite(LED9pin, LOW);            //turns off LED 9
       digitalWrite(LED10pin, HIGH);            //turns on LED 10
       }
     }
   while (digitalRead(PIR9pin) == LOW);            //if PIR is low, then it repeats this specific sequence

   do                                    //check if PIR sensor is high, but if its low then
    {                                    //it keeps checking until its high
     if(digitalRead(PIR10pin) == HIGH)            //Checks if PIR sensor is High
      {
       digitalWrite(LED10pin, LOW);            //turns off LED 10
       digitalWrite(LED1pin, HIGH);            //turns on LED 1
      }
    }
   while (digitalRead(PIR10pin) == LOW);        //if PIR is low, then it repeats this specific sequence
  }
 }

Please help me as soon as possible! This is very important for these people and my graduation!

Thanks!!

-Live Long and Prosper

[timestamp=1292373076]

This just screams for the use of arrays. The LED pins should be in one array. The PIR pins should be in another array.

Then, you need a function to turn off an LED and turn on the next LED (pass the function the index into the array), and wait for a PIR sensor to go HIGH, using the same index into the PIR array.

Return from the function when the PIR sensor goes HIGH.

Call the function in a loop, for each LED/PIR pin pair in order.

When the loop ends, so does the iteration of loop, so it starts all over again.

Way less code than you have here.

That sounds good, but how do I do that? Could you give me an example bit of code so I may start that? I had a freind tell me that but, he didnt know how to do it either.

And how can I add a buzzer?

Thanks for getting back to me pretty quickly.

-Live Long and Prosper

but how do I do that?

Define some arrays:

int LEDs[] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
int PIRs[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

Create a function:

void doNextHole(int prevLedPin, int nextLedPin, int pirPin)
{
   // Turn off prev LED
   if(prevLEDPin > 0)
     digitalWrite(prevLedPin, LOW);

   // Turn on next LED
   digitalWrite(nextLedPin, HIGH);

   // Wait for PIR to go HIGH
   while(digitalRead(pirPin) == LOW)
   {
      // Do nothing
   }
}

Call that function in a loop:

void loop()
{
   int pLedPin = -1;
   int nLedPin = 0;
   int pirPin = 0;

   for(byte i=0; i<10; i++)
   {
       if(i > 0)
         pLedPin = LEDs[i-1]; // Set previous pin (to turn off)
       nLedPin = LEDs[i]; // Set pin to turn on
       pirPin = PIRs[i]; // Set pin with PIR attached to monitor

       doNextHole(pLedPin, nLedPin, pirPin);
   }
}

Really? Wow, that seems like a simple way of doing things rather than that long code I was using...

So, im guessing this defines everything:

int LEDs[] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
int PIRs[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

This is void setup

void doNextHole(int prevLedPin, int nextLedPin, int pirPin)
{
// Turn off prev LED
if(prevLEDPin > 0)
digitalWrite(prevLedPin, LOW);

// Turn on next LED
digitalWrite(nextLedPin, HIGH);

// Wait for PIR to go HIGH
while(digitalRead(pirPin) == LOW)
{
// Do nothing
}
}

and this is void loop:

void loop()
{
int pLedPin = -1;
int nLedPin = 0;
int pirPin = 0;

for(byte i=0; i<10; i++)
{
if(i > 0)
pLedPin = LEDs[i-1]; // Set previous pin (to turn off)
nLedPin = LEDs*; // Set pin to turn on*
_ pirPin = PIRs*; // Set pin with PIR attached to monitor*_
* doNextHole(pLedPin, nLedPin, pirPin);*
* }*
} [/color]
Right?
so with this, I can sequence the LED's so that,
When you stick your hand in Cubby #1 the #1 light will turn off and #2 will turn on
you stick your hand in Cubby #2 and #2 light will turn off, and #3 light will turn on
Sorry to sound insistent, but how can i incorporate a buzzer on this?
if light #1 is on, and you stick your hand in any other cubby hole, the buzzer sounds until you you stick your hand in #1 to fix it?
And just as a question could my code have worked properly?
[timestamp=1292439932]

This is void setup

No. You still need a setup() function.

how can i incorporate a buzzer on this?

Replace the Do nothing part of the loop with something to do. That something to do is to read each of the other PIR pins, and activate the buzzer if the PIR is HIGH. (You know which one you don't need to read.)

  // Wait for PIR to go HIGH
  while(digitalRead(pirPin) == LOW)
  {
     // Do nothing
  }

And just as a question could my code have worked properly?

I presume that you posted here because you knew the answer to that question. If not, try it.

Ill get to writing that right now, whenever I get that written ill post it here to see if I got it right

any other advice would be helpful from anybody! im going to keep this post open so i can get more input on this!

Thanks!

-Live Long and Prosper

[timestamp=1292452764]

HELLPPPP! I have an error i do not know how to fix!

int LEDs[] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20};      //LED array setting them up
int PIRs[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};             //PIR array setting them up
int PIRgpin=21;                                                  //LED to see that the apparatus is on and working properly
int BUZZpin=22;                                               //Buzzer pin


void doNextHole(int prevLedPin, int nextLedPin, int pirPin)
{
  
  if(prevLEDPin > 0);                                    // Turn off prev LED
    digitalWrite(prevLedPin, LOW);

 
  digitalWrite(nextLedPin, HIGH);                       // Turn on next LED

 
  while(digitalRead(pirPin) == LOW);                     // Wait for PIR to go HIGH
  {
   digitalWrite(BUZZpin, HIGH);                        // turn on buzzer
  }
}


void loop()
{
  int pLedPin = -1;
  int nLedPin = 0;
  int pirPin = 0;

  for(byte i=0; i<10; i++)
  {
      if(i > 0)
        pLedPin = LEDs[i-1]; // Set previous pin (to turn off)
      nLedPin = LEDs[i]; // Set pin to turn on
      pirPin = PIRs[i]; // Set pin with PIR attached to monitor

      doNextHole(pLedPin, nLedPin, pirPin);
  }
}

i get an error =

gaston_skills_updated.cpp: In function 'void doNextHole(int, int, int)':
gaston_skills_updated:9: error: 'prevLEDPin' was not declared in this scope

gaston skills updated is the name of the program, but the rest is an error message. please help quick!

I have already stated what im trying to do,so now all i need is help programming.

another question, how can i put in this program that i am using Parallax PIR sensors?

i wrote a short little code to try to test my sensor, but nothing happened.

int PIRpin=52;
int LEDpin=22;

void setup()
{
  pinMode(PIRpin, OUTPUT); 
  pinMode(LEDpin, INPUT);
}

void loop()
{
  if(digitalRead(PIRpin) == HIGH);
  {
    digitalWrite(LEDpin, HIGH);
    delay(1000);
    digitalWrite(LEDpin, LOW);
  }
}

what did i do wrong? all i want that bit to do, is to turn the led on when the sensor is tripped. but nothing happens. What did I do wrong? What else is needed? Because i need to update my program for this project to use the PIR sensors.

please help soon!

im sorry if i seem to be asking you or any other forum members to write this program for me, but i am totally lost, this project is turning out more complicated than i originally anticipated.

Right now i have all of my resistors soldered onto my leds, and the rest of the materials. but thats about it.

Live Long and Prosper.

void doNextHole(int [glow]prevLedPin[/glow], int nextLedPin, int pirPin)
{
  
  if([glow]prevLEDPin[/glow] > 0);                                    // Turn off prev LED
    digitalWrite([glow]prevLedPin[/glow], LOW);

Case matters.

i wrote a short little code to try to test my sensor, but nothing happened.

  pinMode(PIRpin, OUTPUT);
  if(digitalRead(PIRpin) == HIGH);

Generally, reading from an output pin is not very productive.

Writing to an input pin is similarly an exercise in futility.

int LEDs[] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20};      //LED array setting them up
int PIRs[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};             //PIR array setting them up
int LEDgpin=21;
int BUZZpin=22;


void setup()
{
  doNextHole(int prevLedPin, int nextLedPin, int pirPin)
  if(prevLedPin > 0);     // Turn off prev LED
    digitalWrite(prevLedPin, LOW);

 
  digitalWrite(nextLedPin, HIGH);                       // Turn on next LED

 
  while(digitalRead(pirPin) == LOW);                     // Wait for PIR to go HIGH
  {
   digitalWrite(BUZZpin, HIGH);                        // turn on buzzer
  }
}


void loop()
{
  int pLedPin = -1;
  int nLedPin = 0;
  int pirPin = 0;

  for(byte i=0; i<10; i++)
  {
      if(i > 0)
      pLedPin = LEDs[i-1]; // Set previous pin (to turn off)
      nLedPin = LEDs[i]; // Set pin to turn on
      pirPin = PIRs[i]; // Set pin with PIR attached to monitor

      doNextHole(pLedPin, nLedPin, pirPin);
  }
}

Error message:

gaston_skills_updated.cpp: In function 'void setup()':
gaston_skills_updated:8: error: expected primary-expression before 'int'
gaston_skills_updated:8: error: expected primary-expression before 'int'
gaston_skills_updated:8: error: expected primary-expression before 'int'
gaston_skills_updated:8: error: 'doNextHole' was not declared in this scope
gaston_skills_updated:9: error: expected `;' before 'if'
gaston_skills_updated:10: error: 'prevLedPin' was not declared in this scope
gaston_skills_updated:13: error: 'nextLedPin' was not declared in this scope
gaston_skills_updated:16: error: 'pirPin' was not declared in this scope
gaston_skills_updated.cpp: In function 'void loop()':
gaston_skills_updated:36: error: 'doNextHole' was not declared in this scope

Im not understanding what is going on here. whats wrong with the code and how can it be fixed?

  pinMode(PIRpin, OUTPUT);

if(digitalRead(PIRpin) == HIGH);





Generally, reading from an output pin is not very productive.

Writing to an input pin is similarly an exercise in futility.

so wait, huh? what does that mean, and how would i be able to read the input of the PIR sensor unless its with digital read?

could you write or someone else write a quick little code so that when you move your hand over the sensor, an LED come on, then turns off? This will help me greatly by showing my how i will need to write code with these PIR sensors.

  doNextHole(int prevLedPin, int nextLedPin, int pirPin)

If this is a function declaration, it does not belong in setup(). If it is a function call, you don't specify the argument types in a call. You do end the call with a semicolon.

so wait, huh? what does that mean, and how would i be able to read the input of the PIR sensor unless its with digital read?

You do read the output of a PIR sensor with digitalRead. But the output of a sensor is input to the pin, so the pinMode is INPUT. Similarly, when you need to write to a pin, to turn the pin on, the pinMode is OUTPUT.

Could you give me an example of what you are saying about this? i dont get it.

You do read the output of a PIR sensor with digitalRead. But the output of a sensor is input to the pin, so the pinMode is INPUT. Similarly, when you need to write to a pin, to turn the pin on, the pinMode is OUTPUT.

this makes sense... kindave. if i had a sample of source code that used PIR sensors then i could write my code a little bit better.

please help me quick, my teachers are getting a little itchy about getting this done.

[edit]Wait!! never mind!!!! i got that part! holy cow im stupid! i had my pir sensor as an output, and the led as an input! geeze! how could i have over looked that![/edit]

and another question, would a phone call or an instant message chat be appropriate? I think if i talked to you one on one, i might be able to word my questions better, and/or be able to fix this code and make it work a lot quicker.

Live Long and Prosper.

int LEDs[] = {11, 12, 13, 14, 15, 16, 17, 18, 19, 20};      //LED array setting them up
int PIRs[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};             //PIR array setting them up
int LEDgpin=21;
int BUZZpin=22;
doNextHole{int prevLedPin, int nextLedPin, int pirPin};

void setup()
{

  if(prevLedPin > 0);     // Turn off prev LED
    digitalWrite(prevLedPin, LOW);


  digitalWrite(nextLedPin, HIGH);                       // Turn on next LED


  while(digitalRead(pirPin) == LOW);                     // Wait for PIR to go HIGH
  {
   digitalWrite(BUZZpin, HIGH);                        // turn on buzzer
  }
}


void loop()
{
  int pLedPin = -1;
  int nLedPin = 0;
  int pirPin = 0;

  for(byte i=0; i<10; i++)
  {
      if(i > 0)
      pLedPin = LEDs[i-1]; // Set previous pin (to turn off)
      nLedPin = LEDs[i]; // Set pin to turn on
      pirPin = PIRs[i]; // Set pin with PIR attached to monitor

      doNextHole(pLedPin, nLedPin, pirPin);
  }
}

error message:
gaston_skills_updated:4: error: function definition does not declare parameters
gaston_skills_updated.cpp: In function 'void setup()':
gaston_skills_updated:9: error: 'prevLedPin' was not declared in this scope
gaston_skills_updated:10: error: 'prevLedPin' was not declared in this scope
gaston_skills_updated:13: error: 'nextLedPin' was not declared in this scope
gaston_skills_updated:16: error: 'pirPin' was not declared in this scope
gaston_skills_updated.cpp: In function 'void loop()':
gaston_skills_updated:36: error: 'doNextHole' was not declared in this scope

help! idk how to make it right!

Live Long and Prosper

The function declaration for doNextHole needs to start with a return type. If doNextHole does not return anything, the return type is void.

Lacking a return type, the compiler sees this as a function call, not a function prototype.

The Arduino will generate the proper function prototype based on the function implementation, so defining the prototype is not necessary, in this case.

Soooo.... What do I do? what do I need to write? What needs to be added or taken away?

Remove the doNextHole(...); line. It is not a function, it is a function prototype. The Arduino IDE will create one (correctly) when you create the function, which looks like

void doNextHole(int this, int that, int theOtherThing)
{
   // Do something
}
  1. Do I need a resistor for each LED if the LED's are 3.5v and the output on my Arduino is 3.5?

I have asked this before and the answer I got was yes. Current and voltage are not the same.

In this case you are running a single LED at a time. If you do a project that needs to run quite a few LEDs, then I normally use a 5v power supply like a standard USB power supply for an iPhone. Be sure to connect the ground on the power supply with the arduino ground. I personally do not power anything over a couple of LEDs via the arduino (anymore).

Regardless of running your 5v from the arduino or the power supply, you will need a resistor for each LED. I use a 100 ohms resistor for LEDs that require 3.2v, such as RGB Green and Blue legs and most bright white LEDs and a 180ohm for the Red (2v) LEDs. Of course check your LED requirements and test with some resistors before doing your build.

Programming Advice
You should never have a program written and not know if it works but instead work one step at a time. Start with the smallest working code you can get and work up slow from there.

I would write down the logic in plain language and then work on each part of the problem as an individual problem. Once you have each of your units working and you understand fully what is happening, you can put it all together. For a project like yours I would be working something like the following path....

  1. Get the process to light up led 1 and when I put my hand in the box 1, it turns off.
  2. Next get it to turn on the next led when it turns off the primary one and maybe get the full lighting loop working at this time.
  3. Get the process to light up led1 and then put hand in any other LED and see that the buzzer goes off.
  4. Now that basic code is working, time to code the process to assure the correct box is chosen based on "current box" and if so, cycle to the next box. if not, kick off the buzzer and do not cycle to next box.

Note: You may need code like this (untested) to turn off the last LED when you turn on the first LED or when it loops back to the first LED your last one will still be on.

      if(i > 0){
          pLedPin = LEDs[i-1]; // Set previous pin (to turn off)
        } else {
          pLedPin = LEDs[9]; // Set previous pin (to turn off) - in this case - set the last off if moving to next
        }

Programming can be tons of fun once you get the hang of it, so hang in there and I hope this helps.

Soooo.... What do I do? what do I need to write? What needs to be added or taken away?

That's hard to say, since we have no idea what doNextHole is supposed to do. All I can tell you is that you need to a return type and a body to the function.