Error: Variable or field 'setup' declared void

Hey!
I got a problem with this code.. I got this error: "variable or field 'setup' declared void". Arduino marked the lines at the end of the skript. Does anyone know what the problem is? Thank you in advance!

#include <Wire.h>
#include <Adafruit_RA8875.h>
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#define TFT_CS     15
#define TFT_RST    0
#define TFT_DC     4
#define ST7735_ORANGE   0x03DF
// Option 1 (recommended): must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

// Option 2: use any pins but a little slower!
#define TFT_SCLK 13   // set these to be whatever pins you like!
#define TFT_MOSI 11   // set these to be whatever pins you like!
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

const int X_REG_H = 0x1D;
const int X_REG_L = 0x1E;

const int Y_REG_H = 0x1F;
const int Y_REG_L = 0x20;

const int Z_REG_H = 0x21;
const int Z_REG_L = 0x22;


const char DLPF_FS_SEL_0 = 1 << 3;
const char DLPF_FS_SEL_1 = 1 << 4;
const char DLPF_CFG_0 = 1 << 0;
const char DLPF_FS = 0x16;


class ITG {
  int address;
  void read_reg(int REG, char *buff_char);
  void write_reg(int REG, char *buff_char);
public:
  ITG(int addr);
  void read_data(int REG_H, int REG_L, short *data);
  void start();

};

ITG::ITG(int addr) {
address = addr;
}

void ITG::write_reg(int REG, char *buff_char) {
Wire.beginTransmission(address);
Wire.write(REG);
Wire.write(*buff_char);
Wire.endTransmission();
}


void ITG::read_reg(int REG, char *buff_char) {
//*buff_char = 0;

Wire.beginTransmission(address);
Wire.write(REG);
Wire.endTransmission();

Wire.beginTransmission(address);
Wire.requestFrom(address, 1);
//Serial.println(Wire.read(), BIN);

//*buff_char = Wire.read();

if (Wire.available()) {
  *buff_char = Wire.read();
  //Serial.println(*buff_char);
}

Wire.endTransmission();
}

void ITG::start() {
char data = (DLPF_FS_SEL_0 | DLPF_FS_SEL_1 | DLPF_CFG_0);
write_reg(0x16, &data);
data = 9;
write_reg(0x15, &data);

}

void ITG::read_data(int REG_H, int REG_L, short *data) {
char *buff = new char;
read_reg(REG_H, buff);

*data = *buff << 8;
*buff = 0;
read_reg(REG_L, buff);
*data |= *buff;

delete buff;
buff = NULL;

}

int itg_address = 0x68;
ITG gyro(itg_address);

void setup() {
Wire.begin();
Serial.begin(115200);
gyro.start();

}

short dataX, dataY, dataZ;

void loop() {
delay(50);
gyro.read_data(X_REG_H, X_REG_L, &dataX);
gyro.read_data(Y_REG_H, Y_REG_L, &dataY);
gyro.read_data(Z_REG_H, Z_REG_L, &dataZ);


Serial.println(dataX);
Serial.println(dataY);
Serial.println(dataZ);

}



// Ab hier wird der Blinker eingebuden.




void blinker() {
if ((dataX or dataY or dataZ) >= (200)) {
   void setup((void)) {
    Serial.begin(9600);
    Serial.print("Lade Blinkerprogramm");
    tft.initR(INITR_BLACKTAB);

    Serial.println("Blinkerprogramm geladen");
    delay(1000);
  }
}

  
  and


{
  void loop() {
    tft.fillScreen(ST7735_BLACK);
    delay(500);
    tft.fillScreen(ST7735_ORANGE);
    delay(500);
  }

}
}
}

You can't put a function, like setup(), inside a function, like blinker(). You also can't put a loop() function in there.

You can only have one setup() function ad one loop() function.

Thanks a lot. Do you know how to write the code so the code works? :slight_smile:

RdmGuy:
Thanks a lot. Do you know how to write the code so the code works? :slight_smile:

It looks like all of the problems are in the function named "blinker()". Remove that function and maybe the sketch will compile. Then you can start adding features.
Note: This expression will almost certainly no do what you appear to want it to do:

if ((dataX or dataY or dataZ) >= (200)) {

The language won't compare multiple values that way. You probably want to say:

if ((dataX >= 200) || (dataY >= 200) || (dataZ >= 200)) {