Error compiling project for Arduino WiFi shield

Im trying to build an arduino WiFi shield that controls a motor and sounds a buzzer depending on the wifi signal strength.
I borrowed a template from my friend when he did a similar project but found out theres alot of errors in it.
Anyone can help me troubleshoot it?

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiUdp.h>
#include "pitches.h"


char ssid[] = "AndroidJ";     //  your network SSID (name)
char pass[] = "*********";  // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
/*Assign IO pins and global variable*/
int piston = 3;
int melody[] = {NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
void setup() {
 //Initialize serial and wait for port to open:
 Serial.begin(9600);
 while (!Serial) {
   ; // wait for serial port to connect. Needed for Leonardo only
 }

 // check for the presence of the shield:
 if (WiFi.status() == WL_NO_SHIELD) {
   Serial.println("WiFi shield not present");
   // don't continue:
   while (true);
 }

 String fv = WiFi.firmwareVersion();
 if ( fv != "1.1.0" )
   Serial.println("Please upgrade the firmware");

 // attempt to connect to Wifi network:
 while ( status != WL_CONNECTED) {
   Serial.print("Attempting to connect to WPA SSID: ");
   Serial.println(ssid);
   // Connect to WPA/WPA2 network:
   status = WiFi.begin(ssid, pass);

   // wait 10 seconds for connection:
   delay(10000);
 }

 // you're connected now, so print out the data:
 Serial.print("You're connected to the network");
 printCurrentNet();
 printWifiData();

}

void loop() {
 // check the network connection once every 10 seconds:
 delay(10000);
 printCurrentNet();
}

void printWifiData() {
 // print your WiFi shield's IP address:
 IPAddress ip = WiFi.localIP();
 Serial.print("IP Address: ");
 Serial.println(ip);
 Serial.println(ip);

 // print your MAC address:
 byte mac[6];
 WiFi.macAddress(mac);
 Serial.print("MAC address: ");
 Serial.print(mac[5], HEX);
 Serial.print(":");
 Serial.print(mac[4], HEX);
 Serial.print(":");
 Serial.print(mac[3], HEX);
 Serial.print(":");
 Serial.print(mac[2], HEX);
 Serial.print(":");
 Serial.print(mac[1], HEX);
 Serial.print(":");
 Serial.println(mac[0], HEX);

}

void printCurrentNet() {
 // print the SSID of the network you're attached to:
 Serial.print("SSID: ");
 Serial.println(WiFi.SSID());

 // print the MAC address of the router you're attached to:
 byte bssid[6];
 WiFi.BSSID(bssid);
 Serial.print("BSSID: ");
 Serial.print(bssid[5], HEX);
 Serial.print(":");
 Serial.print(bssid[4], HEX);
 Serial.print(":");
 Serial.print(bssid[3], HEX);
 Serial.print(":");
 Serial.print(bssid[2], HEX);
 Serial.print(":");
 Serial.print(bssid[1], HEX);
 Serial.print(":");
 Serial.println(bssid[0], HEX);

 // print the received signal strength:
 long rssi = WiFi.RSSI();
 Serial.print("signal strength (RSSI):");
 Serial.println(rssi);

 // print the encryption type:
 byte encryption = WiFi.encryptionType();
 Serial.print("Encryption Type:");
 Serial.println(encryption, HEX);
 Serial.println();
}

//Write Map Voltage to PWM pin to control LED brightness
analogWrite(ledPin, ledLevel);
// check the network connection once every 10 seconds:
// Detect the SWitch status is LOW and switch input is HIGH
 printCurrentNet();
 {
 if (WiFi.RSSI()>0)
 {
 tone(2,125);
 digitalWrite(piston,HIGH);
 Serial.print("WiFi signal is higher than 0");
 }
 else
 {
   //Set switch status read from switch input
   noTone(2);
   digitalWrite(piston,LOW);
   Serial.print("WiFi signal is lower than 0");
   delay(1000);
 }
   //Turn On or Off LED base in switch press
  }
  }

  void printWifiData() (
Arduino: 1.6.5 (Windows 8.1), Board: "Arduino Uno"

Arduino_WiFi.ino:129: error: expected constructor, destructor, or type conversion before '(' token
Arduino_WiFi.ino:132: error: expected constructor, destructor, or type conversion before ';' token
Arduino_WiFi.ino:133: error: expected unqualified-id before '{' token
expected constructor, destructor, or type conversion before '(' token

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

You really should have read the How to use this forum - please read post at the top of the index page and How to use this forum before posting.

ie Your code and any error messages should always be placed between code tags. Posting it inline as you have done makes it much harder to read or copy and paste for diagnosis.

It's still not too late to edit your post and do this. You'll make potential helpers much happier. :)

And you didn't post it all, so we can't see all of the errors. It's cut off at the bottom, with an error right at the end.

Are you using a Leonardo, or another Arduino?

Edit: For one thing, you have all of this outside of any function:-

//Write Map Voltage to PWM pin to control LED brightness
analogWrite(ledPin, ledLevel);
// check the network connection once every 10 seconds:
// Detect the SWitch status is LOW and switch input is HIGH
printCurrentNet();
{
    if (WiFi.RSSI() > 0)
    {
        tone(2, 125);
        digitalWrite(piston, HIGH);
        Serial.print("WiFi signal is higher than 0");
    }
    else
    {
        //Set switch status read from switch input
        noTone(2);
        digitalWrite(piston, LOW);
        Serial.print("WiFi signal is lower than 0");
        delay(1000);
    }
    //Turn On or Off LED base in switch press
}
}

void printWifiData() (

And use a meaningful title!! "Help" tells us nothing of what the question is about. The title should supply enough info to let us know if the subject is something we are able to help with.

Weedpharma

In a Forum whose primary purpose is helping people the title "Help" is about as useful as a grain of sand in the Sahara desert.

I hope the OP gave a little more thought to figuring out the problem in his project.

...R

go to the forum and click on any of the topics

the first or second sticky post will be

|500x174

this is very interesting. it has one statement and one command.

scroll down to topics #6 and #7

then come back to your first post, click on the edit button on the bottom right change your first post.

highlight all your code and hit the enter code tags.

then delete your subject line and put in something that has to do with your actual problem.

this my fiend is the actual help you need at this moment.

.