Issue with Arduino primo when uploading sketch

I’m using an arduino primo with the Arduino IDE 1.8.5
I have selected it as a board and the appropriate serial port.
When compiling I have no issue, however when I go to upload I receive the following message(see attachments).

My code is this, but it doesn’t work with any sketch, not even blink or helloWorld.

#include <LiquidCrystal.h>  // include the library code for the LCD
#include <math.h>           // include the library code for pow() and log() functions
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

int sensorPin = A0;     // select the input pin for the thermistor
int sensorValue = 0;    // variable to store the value coming from the sensor
int motorPin1 = 8;      // select the pin for the motor
int motorPin2 = 9;      // select the pin for the motor
int PTM = 13;           // select the input pin for the
int PTMValue = 0;       // variable to store the value coming from the switch

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // declare the motorPin's as an OUTPUT:
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  // declare the PTM as an INPUT:
  pinMode(PTM, INPUT);
  // declare all unused pins as OUTPUT's:
  pinMode(1, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(13, OUTPUT);

void loop()
  while (PTMValue == 0)   // while PTM not pressed
    PTMValue = digitalRead(PTM);
    if (PTMValue == 1)   // PTM pressed
      PTMValue = 1;
      PTMValue = PTMValue;
   // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  //convert the value from sensor to temperature:
  sensorValue = 1 + pow(log(sensorValue)/8.529568, 0.9588075);
  sensorValue = -343.6405 + (606.1934)/(sensorValue);
  //round sensorValue to nearest integer:
  sensorValue = rint(sensorValue);
  //turn on motor
  digitalWrite(motorPin1, HIGH);
  //print ("Temp =", sensorValue) to LCD:
  lcd.setCursor(0, 0);
  lcd.print("Temp =");
  lcd.setCursor(8, 0);
  //print whether or not cooler is ON/OFF:
  if (sensorValue>= 30)
    lcd.setCursor(0, 1);
    lcd.print("Cooler: ON");
    lcd.setCursor(0, 1);
    lcd.print("Cooler: OFF");

I have a project due in a number of days, being able to install the program onto the board is only kinda important. Anyone with any suggestions/possible fixes, I think ye know what to do :thumbs-up:

Preferences and serial port.pdf (343 KB)

Error Message.pdf (68 KB)