Fehler im Code

Gast #6409681
Lesenswert?

Hallo

Ich bau mir gerade einen Selfbalance Roboter.
Bis jetzt hat alles gut geklappt bis auf das Arduino Programm!
Wenn ich den Code auf den Arduino laden will kommt immer der error!

exit status 1
'DRIVER_PIN' was not declared in this scope

Hier der teil vom Code:
/*********************************************************************** 
***************/
/************        Initialize the Timers and Registers 
******************/
/*********************************************************************** 
***************/
void initOutput() {
  /****************            mark all driver pins as Output 
******************/
 🎈 for(uint8_t i=0;i<5;i++) {

    pinMode(DRIVER_PIN[i],OUTPUT);
  }🎈

  /********  Specific Timers & Registers for the atmega328P (Promini) 
************/
#if defined(PROMINI)

  digitalWrite(4,HIGH);   // Disable motors

  //We are going to overwrite the Timer1 to use the stepper motors

  // STEPPER MOTORS INITIALIZATION
  // TIMER1 CTC MODE
  TCCR1B &= ~(1<<WGM13);
  TCCR1B |=  (1<<WGM12);
  TCCR1A &= ~(1<<WGM11);
  TCCR1A &= ~(1<<WGM10);

  // output mode = 00 (disconnected)
  TCCR1A &= ~(3<<COM1A0);
  TCCR1A &= ~(3<<COM1B0);

  // Set the timer pre-scaler
  // Generally we use a divider of 8, resulting in a 2MHz timer on 16MHz 
CPU
  TCCR1B = (TCCR1B & ~(0x07<<CS10)) | (2<<CS10);

  //OCR1A = 125;  // 16Khz
  //OCR1A = 100;  // 20Khz
  OCR1A = 80;   // 25Khz
  TCNT1 = 0;

  TIMSK1 |= (1<<OCIE1A);  // Enable Timer1 interrupt
  digitalWrite(4, LOW);   // Enable stepper drivers

#endif

  /****************  Specific Timers & Registers for the MEGA's 
******************/
#if defined(MEGA)
#endif

  /******** Specific Timers & Registers for the atmega32u4 (Promicro) 
************/
#if defined(PROMICRO)
#endif

}
Der Absatz mit die Ballons ist der, der Probleme macht.

Ich habe den Code nicht selbst geschrieben

Hier ein Link zur Bauanleitung:

https://www.youtube.com/watch?v=aUbBUd-hBLI

Ich bin für jede Antwort dankbar und Danke im Vorhinein.
Angehängte Dateien:
Gast #6409820
Lesenswert?

https://github.com/mahowik/BalancingWii/blob/master/Output.cpp

Da steht ja:
1
#if defined(PROMINI)
2
  uint8_t DRIVER_PIN[5] = {5,6,7,8,4};  
3
 //STEP1 (PORTD 5), STEP2 (PORTD 6), DIR1 (PORTD 7), DIR2 (PORTB 0), ENABLE
4
#endif
5
#if defined(PROMICRO)
6
#endif
7
#if defined(MEGA)
8
#endif


Was sind diese PROMINI | PROMICRO | MEGA - Macros? Wahrscheinlcih die 
Namen von Arduino-Boards?
Gast #6410990
Lesenswert?

99 Luftballons schrieb:
> Was sind diese PROMINI | PROMICRO | MEGA - Macros? Wahrscheinlcih die
> Namen von Arduino-Boards?

Wohl eher nicht.

In def.h wird der Typ des µC ausgewertet
1
/**************************************************************************************/
2
/***************             Proc specific definitions             ********************/
3
/**************************************************************************************/
4
// Proc auto detection
5
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)
6
  #define PROMINI
7
#endif
8
#if defined(__AVR_ATmega32U4__) || defined(TEENSY20)
9
  #define PROMICRO
10
#endif
11
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
12
  #define MEGA
13
#endif

Ivan Orsolic schrieb:
> Wenn ich den Code auf den Arduino laden ...

Zum Glück gibt es nur einen einzigen Arduino.
Welcher Prozessor sitzt auf deinem Board und setzt deine IDE die 
Definition für den Prozessor richtig?

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren