An error occurred while uploading the sketch

I have the following sketch

/*
 * =====  
 */
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

 // Control serial output
bool debug = true;
// do things during testing
bool testing = true;

// for nRF24L0
#define CE_PIN   9
#define CSN_PIN 10

// for actuator
#define actOnPin A0   // turn actuator on
#define actRunPin 3  // pwm running
#define actWayPin A1  // direction
#define actOverPin A2 // turntable finished turning
bool    actExtended  = false;  // position
bool    actExtending = true;  // direction      


// for radio
const byte slaveAddress[5] = {'R','x','A','A','A'};
const byte masterAddress[5] = {'T','X','a','a','a'};

RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

int dataReceived[2]; // to hold the data from the slave - must match replyData[] in the slave
bool newData = false;
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second


 // Commands - THESE MUST BE IDENTICAL TO THOSE IN TROLLEY
const char ignore[]  = {'I'};
const char active[]  = {'A'};
const char start[]   = {'S'};
const char restart[] = {'R'};
const char paused[]  = {'P'};
const char parked[]  = {'K'};
const char onTT[]    = {'O'};
const char desist[]  = {'X'};
      char dataIn[]  = {' '};

 /*       
 * Forward declare subroutines
 */

// Send message to Trolley
void send(char message[]);

 // Receive data from Console
void getData();

// For debug purposes show what happened
void showData();

// take over loop control and run the process
void runConsole();

// wait for command from Console
void getCommand();

// Respond to transmission
void respondToTx();

// rotate turntable
void turnTurntable();

/*
 * ====================
 */

void setup() {

    if (debug) Serial.begin(9600);

    if (debug) Serial.println("Console Starting");

    pinMode(actOnPin,   OUTPUT);
    pinMode(actRunPin,  OUTPUT);
    pinMode(actWayPin,  OUTPUT);
    pinMode(actOverPin, INPUT);
    digitalWrite(actOnPin, LOW);
    digitalWrite(actRunPin, LOW);
    digitalWrite(actWayPin, LOW);
    digitalWrite(actOverPin, LOW);

    radio.begin();
    radio.setDataRate( RF24_250KBPS );

    radio.openWritingPipe(slaveAddress);
    radio.openReadingPipe(1, masterAddress);
    
    // Set radio for transmission checking
    //    includes enable.dynamicPayloads
    radio.enableAckPayload();

    radio.setRetries(3,5); // delay, count
//    send(command[0]); // to get things started
//    prevMillis = millis(); // set clock
}

//=============

void loop() 
{
//    send(&ignore[0]);  // 'I'
//    prevMillis = millis();
//    getData();
//    showData();
//
    send(&start[0]);  // 'S'
    prevMillis = millis();
    getData();
    showData();

    // go to work
    runConsole();
}  // end loop()    

//====================

void send(char message[]) 
{
  // Create local flags
  bool waitedLongEnough = false;
  bool result = false;

  // Create waiting loop
  while (!waitedLongEnough)
  {
     // Get the current time
     currentMillis = millis();
     // Compare it to the time of last transmission
     if (currentMillis - prevMillis >= txIntervalMillis) 
     {
        // Close the ears
        radio.stopListening();
        // Use it      
        result = radio.write(message, 1);
        // Open the ears
        radio.startListening();

//        // flush the transmission buffer
//        radio.flush_tx();
        
        // Set the flag to exit loop
        waitedLongEnough = true;        
     }else{
      // wait a bit longer
      delay(10);
     }  // end if/else (currentMillis - prevMillis
  } // end while (!waitedLongEnough)

  if (debug)
  {
    Serial.print("Data sent >");
    Serial.print(message);
    Serial.println("<");

  }  // end if(debug)
      
  if (result) 
  {
    if (debug) Serial.println("Console.send - Acknowledge received from Trolley");
  }else{
    if (debug) Serial.println("Console.send - Tx failed");
  }  // end if/else if (rslt)
}  // end send(char message[]) 

//================

void getData() 
{
  // say you're here
  if (debug) Serial.println("Console.getData - waiting");

  if ( radio.available() ) 
  {
      radio.read( &dataReceived, sizeof(dataReceived) );
      newData = true;
  }
}

//================

void showData() {
    if (newData == true) 
    {
      if (debug)
      {
        Serial.print("Data received ");
        Serial.print(dataReceived[0]);
        Serial.print(", ");
        Serial.println(dataReceived[1]);
        Serial.println();
      }  // end  if (debug)
        newData = false;
    }  // end if (newData == true)
}  // end showData()

/*
 * ====================
 */

 // take over loop control and run the process
void runConsole()
{
  // assert: Console is in Listening mode
    if (debug) Serial.println("Entering runConsole()");
 
  // create the lock
  bool running = true;

  //  lock the process here
  while (running)
  {
    // wait for command from Trolley and act on it
    getCommand();
    respondToTx();

  }  // end while running
}  // end runConsole

/*
 * ===============
 */
 
// wait for command from Console
void getCommand()
{
  if (debug) Serial.println("Console.getCommand - waiting command from Trolley");
  
  if ( radio.available() ) 
  {
      radio.read( &dataIn[0], sizeof(dataIn[0]) );
      newData = true;
  }  // end if (radio.available

  if ((debug) and (newData))
  {
    Serial.print("Data read by Console.getCommand >");
    Serial.print(dataIn[0]);
    Serial.println("<");
  }  // end if (debug)  
}  // end getCommand

/*
 * ====================
 */

// Respond to transmission
void respondToTx()
{
  if (newData)
  {
  if (debug) Serial.println("In respondToTx()");

   if (dataIn[0] == onTT[0])
   // assert: trolley is on turntable
   {
      if (debug) Serial.println(">onTT< received");
      turnTurntable();
      send(&start[0]);  // restart the trolley
   }  // end if (dataIn == onTT)
   
    newData = false;  // this line shifted from send()
  }  // end if (newData)
}  // end respondToTx()

/*
 * ====================
 */

// rotate turntable
void turnTurntable()
{
  if (debug) 
  {
    Serial.print("Turning Table ");
  }  //  end if (debug)
  
  // tell Ben turn on the power
  digitalWrite(actOnPin, HIGH);
  
  // on basis of direction
  if (actExtended) // turning anticlockwise
  {
    if (debug) Serial.println ("anticlockwise");
    
    // tell Ben retracting
    digitalWrite(actWayPin, LOW);  // retract
    // tell Ben run motor
    digitalWrite(actRunPin, HIGH);

    //  pretend to run motor
    if (testing) delay(3000);

    // NEED EXTERNAL SIGNAL TO DO THIS
    // wait until actuator turned off
    //while (digitalRead(actOverPin) == LOW) delay(500);
    
    // cancel order to run
    digitalWrite(actRunPin, LOW);
    // change direction setting
    actExtended = !actExtended;    
    
  }else{  // turning clockwise
    if (debug) Serial.println ("clockwise");
        
    // tell Ben extending
    digitalWrite(actWayPin, HIGH);  // extend
    // tell Ben run motor
    digitalWrite(actRunPin, HIGH);

    //  pretend to run motor
    if (testing) delay(3000);

    // NEED EXTERNAL SIGNAL TO DO THIS
    // wait until actuator turned off
    //while (digitalRead(actOverPin) == LOW) delay(500);
    
    // cancel order to run
    digitalWrite(actRunPin, LOW);
    // turn off direction indicator
    digitalWrite(actWayPin, LOW);
    // change direction setting   
    actExtended = !actExtended;     
  }  // end if/else
  
  // cancel order to turn on power
  digitalWrite(actOnPin, LOW);  
}  // end turnClockwise()

It compiles etc. okay but I get this error when I try to upload it.

Sketch uses 4,750 bytes (14%) of program storage space. Maximum is 32,256 bytes.
Global variables use 547 bytes (26%) of dynamic memory, leaving 1,501 bytes for local variables. Maximum is 2,048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:C:\Users\041500~1\AppData\Local\Temp\build4aa935b5cc573e4fd1cf0660f485bc86.tmp/Console.ino.hex:i 
An error occurred while uploading the sketch

Can someone please tell me what is wrong.

Thanks

Which version of the Arduino IDE are you using?

Hi pert

1.6.10

That's a known issue with Arduino IDE 1.6.10/Arduino AVR Boards 1.6.12. Please upgrade to Arduino IDE 1.6.12.

Thanks pert. I'll do that.

I forgot to add -
That sketch I sent at first post was originated using the RF24.h (TMRh20 version). Unfortunately I got confused this morning and installed RF24-master.zip from GitHub on the college computer instead.

Two things from that if I may:

  1. Would that have caused the cause of the problem?
  2. How do I uninstall RF24-master.zip? -- Just delete the .ZIP file?

vagulus:

  1. Would that have caused the cause of the problem?

No, the problem occurs when you start the Arduino IDE by opening a sketch.

vagulus:
2. How do I uninstall RF24-master.zip? -- Just delete the .ZIP file?

No, deleting the .ZIP file will have no effect. When you install the library it is extracted from the zip file and copied to the library folder. To uninstall it delete the folder {sketchbook folder}\libraries\RF24-master. You can find the location of the sketchbook folder at File > Preferences > Sketchbook location.

Thanks again pert. I'll get that on Wednesday morning.

Your assistance much appreciated.