Error messages during compiling

IDE gerelateerde berichten
Berichten: 37
Geregistreerd: 07 Okt 2016, 10:33

Error messages during compiling

Berichtdoor maartentukker » 05 Nov 2023, 20:35

Hello all,

I'm having some issues with my last code. I'm getting error messages, but i cannot see where the problem is. Can somebody help me in the right direction?
Code is:
Code: Alles selecteren
```cpp
/*
-------------- SPOOR ONDER ----------------

    Block detection, Activated Block -1 is isolated, -2 is set free

    Blokdetection by current sensor OKKIE
    Blok_0 is for reference and correct switching of power (without flickering)
*/

// Current sensors (Input from OKKIE)
const int Blok_0 = 3;  // reference block

const int Blok_9 = 5;
const int Blok_10 = 6;
const int Blok_11 = 7;
const int Blok_12 = 8;
const int Blok_13 = 9;
const int Blok_14 = 10;
const int Blok_15 = 11;
const int Blok_16 = 12;


// Sections isolate (output to relais)

const int B7 = 14;
const int B8 = 15;
const int B9 = 16;
const int B10 = 17;
const int B11 = 18;
const int B12 = 19;
const int B13 = 20;
const int B14 = 21;
const int B15 = 22;


// Toggle switch for Track powerless for switching yard

const int S11 = 25;
const int S12 = 26;
const int S13 = 27;
const int S14 = 28;

int S11State = 0;
int S12State = 0;
int S13State = 0;
int S14State = 0;

// Pushbutton for resetting B10

const int Y10 = 29;  // button to set B10 free after entry of switching yard

const int F10 = 30;  // relais F10 to set free track next to B10 when there is a free track on switching yard acc to turnout position and toggleswitch


// Toggle switch input from Arduino 2 turnouts

const int W14 = 25;
const int W15 = 26;
const int W16 = 27;
const int W17 = 28;
const int W18 = 29;
const int W19 = 30;

// State change detection for switches

int W14State = 0;
int W15State = 0;
int W16State = 0;
int W17State = 0;
int W18State = 0;
int W19State = 0;


int lastW14State = 0;
int lastW15State = 0;
int lastW16State = 0;
int lastW17State = 0;
int lastW18State = 0;
int lastW19State = 0;

// State change for blocks  NOT used by current detection method, because of continuous detecting instead of a pulse
// int lastHa1aState, lastHa1bState, lastHa2State, lastHa3State, lastHa4State, lastHa5State, lastHa6State, lastHa7State, lastHa8State, lastHa9State, lastHa10State, lastHa11State, lastHa12aState, lastHa12bState, lastHa13State;

// Timer to clear block after turnout has changed position (change millis and enabled name per switch)
const unsigned long interval = 3000;  // Timer delay setting
unsigned long W_Millis;               // Timer relais for S5 occupancy
bool enabled_W = false;               // Software switch to start and stop timer


void setup() {
  Serial.begin(9600);
  Serial.print("Sketch:   ");
  Serial.println(__FILE__);
  Serial.print("Uploaded: ");
  Serial.println(__DATE__);
  Serial.println(" ");

  // Sensors (OKKIE)

  pinMode(Blok_9, INPUT_PULLUP);
  pinMode(Blok_10, INPUT_PULLUP);
  pinMode(Blok_11, INPUT_PULLUP);
  pinMode(Blok_12, INPUT_PULLUP);
  pinMode(Blok_13, INPUT_PULLUP);
  pinMode(Blok_14, INPUT_PULLUP);
  pinMode(Blok_15, INPUT_PULLUP);
  pinMode(Blok_16, INPUT_PULLUP);


  // Section isolate     Power on all blocks at startup

  pinMode(B7, OUTPUT);
  digitalWrite(B7, HIGH);
  pinMode(B8, OUTPUT);
  digitalWrite(B8, HIGH);
  pinMode(B9, OUTPUT);
  digitalWrite(B9, HIGH);
  pinMode(B10, OUTPUT);
  digitalWrite(B10, HIGH);
  pinMode(B11, OUTPUT);
  digitalWrite(B11, HIGH);
  pinMode(B12, OUTPUT);
  digitalWrite(B12, HIGH);
  pinMode(B14, OUTPUT);
  digitalWrite(B14, HIGH);
  pinMode(B15, OUTPUT);
  digitalWrite(B15, HIGH);

  pinMode(F10, OUTPUT);


  // Input for toggle switch switching yard

  pinMode(S11, INPUT_PULLUP);
  pinMode(S12, INPUT_PULLUP);
  pinMode(S13, INPUT_PULLUP);
  pinMode(S14, INPUT_PULLUP);

  // input of button Y10 to set B10 clear
  pinMode(Y10, INPUT_PULLUP);


  // W14 is toggle switch position for turnout 14, comes from arduino 2

  pinMode(W14, INPUT_PULLUP);
  pinMode(W15, INPUT_PULLUP);
  pinMode(W16, INPUT_PULLUP);
  pinMode(W17, INPUT_PULLUP);
  pinMode(W18, INPUT_PULLUP);
  pinMode(W19, INPUT_PULLUP);
}


void loop() {
  // read the current sensor (Block) input pin:
  int Blok_0_State = digitalRead(Blok_0);

  int Blok_9_State = digitalRead(Blok_9);
  int Blok_10_State = digitalRead(Blok_10);
  int Blok_11_State = digitalRead(Blok_11);
  int Blok_12_State = digitalRead(Blok_12);
  int Blok_13_State = digitalRead(Blok_13);
  int Blok_14_State = digitalRead(Blok_14);
  int Blok_15_State = digitalRead(Blok_15);
  int Blok_16_State = digitalRead(Blok_16);


  // read the turnout (toggle switch) position)

  int W14State = digitalRead(W14);
  int W15State = digitalRead(W15);
  int W16State = digitalRead(W16);
  int W17State = digitalRead(W17);
  int W18State = digitalRead(W18);
  int W19State = digitalRead(W19);


  // Timer reference
  unsigned long currentMillis = millis();

  // Hall sensor LOW, means activated (set previous Block powerless), relay set to LOW (indicator led ON)
  // Track Wires connected to relay in NC position

  // Block 1 occupied
  /*if (Blok_1_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(S4, HIGH);  // 34
    digitalWrite(S3, LOW);   // 35
    delay(10);
  }

  if (W1State != lastW1State)  // Checks if turnout 1 has shifted since last position (which the train used to occupy track Ha1a or Ha1b)
  {
    W_Millis = currentMillis;
    enabled_W = true;  // turn on software timer
  }
  if (enabled_W)  // software timer is active ?
  {
    if (currentMillis - W_Millis >= interval) {
      digitalWrite(S3, HIGH);  // Set block S5 free
      enabled_W = false;       // stop software timer
    }
  }


  // Block 7 occupied
  if (Blok_7_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(S6, HIGH);   // 32
    delay(10);
  }

  // Block 8 occupied
  if (Blok_8_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(S6, HIGH);   // 32
    delay(10);
  }
*/
  // Block 9 occupied
  if (Blok_9_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(B8, LOW);   // Blok 8 powerless
    digitalWrite(B7, HIGH);  // Blok 7 free
    delay(10);
  }

  // Block 10 occupied
  if (Blok_10_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(B9, LOW);   // 35
    digitalWrite(B8, HIGH);  // 30
    delay(10);
  }

  // Block 11 occupied
  if (Blok_11_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(B10, LOW);  // 35
    digitalWrite(B9, HIGH);  // 30
    delay(10);
  }

  // Block 12 occupied
  if (Blok_12_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(B10, LOW);  // 35
    digitalWrite(B9, HIGH);  // 30
    delay(10);
  }

  // Block 13 occupied
  if (Blok_13_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(B10, LOW);  // 35
    digitalWrite(B9, HIGH);  // 30
    delay(10);
  }


  // Block 14 occupied
  if (Blok_14_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(B10, LOW);  // 35
    digitalWrite(B9, HIGH);  // 30
    delay(10);
  }


  // Conditions for switching yard entry via F10
  if (W14State == HIGH && S14State == HIGH)  // W14 HIGH = straight   S14 LOW = toggleswitch inactive, track 14 is free
  {
    digitalWrite(F10, HIGH);  // train track F10 gets power, train may drive to blok 14
    delay(10);
  } else if (W14State == LOW && W15State == HIGH && S13State == HIGH)  // W14 bend, W15 straight and S13 is inactive, track 13 is free
  {
    digitalWrite(F10, HIGH);                                                              // train may drive to blok 13
  } else if (W14State == LOW && W15State == LOW && W16State == HIGH && S12State == HIGH)  // W14 bend, W15 bend, W16 straight and S12 is inactive, track 12 is free
  {
    digitalWrite(F10, HIGH);
  } else if (W14State == LOW && W15State == LOW && W16State == LOW && S11State == HIGH)  // W14 bend, W15 bend, W16 bend and S11 is inactive, track 11 is free
  {
    digitalWrite(F10, HIGH);
  } else {
    digitalWrite(F10, LOW);
  }

  // ---------------------------------------- Write pushbutton code here to reset B10 ----------------------------------------------------


  // Block 15 occupied
  if (Blok_15_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(B11, LOW);  // 32
    digitalWrite(B12, LOW);  // 33
    digitalWrite(B13, LOW);  // 32
    digitalWrite(B14, LOW);
    delay(10);
  }

  // Block 16 occupied
  if (Blok_16_State == LOW && Blok_0_State == HIGH) {
    digitalWrite(B11, HIGH);  // 32
    digitalWrite(B12, HIGH);  // 33
    digitalWrite(B13, HIGH);  // 32
    digitalWrite(B14, HIGH);
    delay(10);
  }




  /* licht signaal Blok 1 na vrijgave door blok 3 afhankelijk van wissel 2
  if (W2State == HIGH && L1aState == HIGH)   // L1aState is de blok vrijgave, zolang deze er niet is blijft alles rood     W2State is wisselsturing wissel 2 vanuit arduino Mega 2  pin ...
  {
    digitalWrite(relaisL1a, HIGH);
    digitalWrite(relaisL1b, LOW);
    delay(10);
  }
  else if (W2State == LOW && L1aState == HIGH)
  {
    digitalWrite(relaisL1a, LOW);       // ene spoor rood andere groen door wisselstand
    digitalWrite(relaisL1b, HIGH);
    delay(10);
  }
  else
  {
    digitalWrite(relaisL1a, LOW);        // Alles op rood, blok bezet
    digitalWrite(relaisL1b, LOW);
    delay(10);
  }

  // licht signaal Blok 9 na vrijgave door blok 7, 8 of 11  (1 relais ivm licht signaal enkel spoor)
  if (W5State == HIGH && L9State == HIGH)   // L9State is de blok vrijgave, zolang deze er niet is blijft alles rood     W5State is wisselsturing vanuit arduino Mega 2  pin ...
  {
    digitalWrite(relaisL9, HIGH);
    delay(10);
  }
  else if (W5State == LOW && L9State == HIGH)
  {
    digitalWrite(relaisL9, LOW);       // enkel licht signaal op block 9
    delay(10);
  }
  else
  {
    digitalWrite(relaisL9, LOW);        // Alles op rood, blok bezet
    delay(10);
  }

  // licht signaal Blok 12 na vrijgave door blok 10
  if (W12State == HIGH && L12aState == HIGH)   // L12State is de blok vrijgave, zolang deze er niet is blijft alles rood     W12State is wisselsturing vanuit arduino Mega 2  pin ...
  {
    digitalWrite(relaisL12a, HIGH);
    digitalWrite(relaisL12b, LOW);
    delay(10);
  }
  else if (W12State == LOW && L12aState == HIGH)
  {
    digitalWrite(relaisL12a, LOW);       // ene spoor rood andere groen door wisselstand
    digitalWrite(relaisL12b, HIGH);
    delay(10);
  }
  else
  {
    digitalWrite(relaisL12a, LOW);        // Alles op rood, blok bezet
    digitalWrite(relaisL12b, LOW);
    delay(10);
  }
*/

  delay(10);  //debounce
}

```



Error messages are:

In file included from C:\Users\silek\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/Arduino.h:32:0,
from C:\Users\silek\AppData\Local\Temp\arduino\sketches\36B34EAFC95DD53DFA4E5AA12D7B14E0\sketch\blok_stroomdetectie_spoor_onder_2.ino.cpp:1:
C:\Users\silek\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/binary.h:39:13: error: expected unqualified-id before numeric constant
#define B10 2
^
C:\Users\silek\Documents\Maarten\Arduino\SPOOR NIEUW 2023\blok_stroomdetectie_spoor_onder_2\blok_stroomdetectie_spoor_onder_2.ino:28:11: note: in expansion of macro 'B10'
const int B10 = 17;
^~~
C:\Users\silek\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/binary.h:46:13: error: expected unqualified-id before numeric constant
#define B11 3
^
C:\Users\silek\Documents\Maarten\Arduino\SPOOR NIEUW 2023\blok_stroomdetectie_spoor_onder_2\blok_stroomdetectie_spoor_onder_2.ino:29:11: note: in expansion of macro 'B11'
const int B11 = 18;
^~~

exit status 1

Compilation error: exit status 1

Advertisement

Berichten: 80
Geregistreerd: 02 Nov 2022, 13:03

Re: Error messages during compiling

Berichtdoor ThHe » 05 Nov 2023, 21:54

Op regel 1 ( die niet in deze code staat) staat een # definie B10 2
En in het programma staat een const B10 = 17
Deze statements zijn strijdig met elkaar.

Berichten: 37
Geregistreerd: 07 Okt 2016, 10:33

Re: Error messages during compiling

Berichtdoor maartentukker » 06 Nov 2023, 21:35

Ah oke, I changed all B... to BL... , now it compiles good.
Tnx

Terug naar Arduino IDE

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 51 gasten