Error compiling code for Arduino Uno

I am currently doing a project in my degree where the use of an Arduino Uno is mandatory. I haven't had much experience with the c++ language at all. The code I have written is for a product which will have 4 LEDs that will turn on randomly and stay on until the use moves the product and the accelerometer reads above a certain threshold of acceleration.
I am currently getting an error message which I really don't understand.
The code seems to be very close to compiling (e.g. compiles for a few seconds), before the error shows.

Does anyone have any suggestions please?

Many thanks in advance.

CODE

#include <Wire.h> 
#include <SparkFun_MMA8452Q.h>
int rand(); 
int button = 4; 
int LED1 = 10; 
int LED2 = 11; 
int LED3 = 12; 

unsigned long randomNumber; // extended variables for number storage
unsigned long time_taken; // only stores positive data
MMA8452Q accel;
int xAcceleration;

void setup()
{
 accel.init();
 Serial.begin(9600);
 pinMode(LED1, OUTPUT); 
 pinMode(LED2, OUTPUT); 
 pinMode(LED3, OUTPUT); 
 pinMode(button, INPUT);  
 randomSeed(analogRead(A0));
}

void rand_light()
{
 digitalWrite(LED1, LOW);
 digitalWrite(LED2, LOW);
 digitalWrite(LED3, LOW);
 randomNumber = random(10, 13); // computing the random number
 Serial.println(randomNumber);
 digitalWrite(randomNumber, HIGH); // turning on the LED of the same number
 acceleration();
}

void acceleration()
{
 accel.read(); // Update acceleromter data
 xAcceleration = accel.x;
 while (xAcceleration <= 2000)
 {
   analogRead;
 }
 rand_light();
}

ERROR

/var/folders/t8/33_90srn4xj5sg6gcn2slx8h0000gn/T//ccbg7JTF.ltrans0.ltrans.o: In function `main':
/private/var/folders/t8/33_90srn4xj5sg6gcn2slx8h0000gn/T/AppTranslocation/4C23B832-9C40-4630-8F2A-1791BE626182/d/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/main.cpp:46: undefined reference to `loop'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

Final.ino (1.17 KB)

READ ---> http://forum.arduino.cc/index.php?topic=149014.0

Is the error something about missing a loop() function? That is all that I can guess from the posted code. If you were to post the error message (in its entirety) we would be more likely to be able to help.

groundFungus:
Is the error something about missing a loop() function? That is all that I can guess from the posted code. If you were to post the error message (in its entirety) we would be more likely to be able to help.

Sorry I forgot to add the error, it I have now edited and added the error.

while (xAcceleration <= 2000)
{
analogRead;
}

  1. This is syntactically incorrect - if you're trying to call analogRead() you need to put the parens after it - like any other function call - and pass it a pin number.

  2. It's an infinite loop, since xAcceleration will never be updated inside the loop. Did you intend to take a reading with the accelerometer and update xAcceleration with it instead?

  3. There is no loop() function. All arduino sketches must have one.

  4. rand_light and acceleration call eachother. If they were ever kicked off, they would recursively call eachother until the call stack filled up available memory space. Instead, you should call them from loop(), so that each one is finishing before the other is called, eg:

void loop() {
rand_light();
acceleration();
}
  1. You posted code but didn't use code tags, this annoys the people who answer questions here. Since you aren't paying us to help you, you should try to make our lives easier and not annoy us.

And please do not edit your original post to update code or include information requested after the original post.