Hi,
I was trying to upload a bit of code to my arduino and I keep getting this error message:
**exit status 1**
**'display' was not declared in this scope**
#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#include <EEPROM.h>
#include <AnalogKey.h>
#include <GyverButton.h>
#define EE_DATA_ADDR 1
#define EE_KEY_ADDR 0
#define EE_KEY 0xBE
#define TFT_CS 10
#define TFT_RST 8
#define TFT_DC 9
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
//
char masschar[5];
String massstring;
int set,setmass,rapidtime;
boolean initial,flagmass, flagmassset, rapidflag, men, disp;
int n=0;//
float input_volt = 0.0;
float temp=0.0;
float r1=330000.0;
float r2=33300.0;
float velocity;
float energy;
volatile unsigned long gap1, gap2;
unsigned long lastshot;
unsigned long Last_time;
boolean butt_flag = 0;
int8_t arrowPos = 0;
volatile unsigned long photocell1=0, photocell2=0, firstShot=0;
volatile int shot1=0,shot2=0;
volatile bool newShot=false;
float photoDistance=0.09082;
int lastShot=0;
int speedBB=0;
bool err=false, dispFlag=false;
bool blocked2=false, blocked3=false;
bool dispClear;
int analog2, analog3;
unsigned long rateFire=0;
unsigned long prMicros2=0,prMicros3=0;
unsigned long clearDisplayTime=5000000, prMicrosClear=0;
void setup() {
attachInterrupt(0,Photo1,RISING);
attachInterrupt(1,Photo2,RISING);
Serial.begin(9600);
display.setBrightness(0x0f);
SEG_ERR[3]=0;
display.setSegments(data);
}
void Photo1() {
photocell1=micros();
if (!newShot) firstShot=photocell1;
shot1++;
newShot=true;
}
void Photo2() {
photocell2=micros();
shot2++;
}
void PrintDisplay() {
Serial.print (speedBB);
Serial.println (" m/s");
Serial.print (rateFire);
Serial.println (" rpm");
dispClear=false;
prMicrosClear=micros();
if (!err && rateFire==0) display.showNumberDec(speedBB, false, 4, 0);
if (!err && rateFire!=0) {
display.showNumberDec(rateFire, false, 4, 0);
rateFire=0;}
if (err) {display.setSegments(SEG_ERR);err=false;}
dispFlag=false;
}
void Setting2() {
analog2=analogRead(A3);
Serial.println(analog2);
data[0] = 0b00000110;
data[1]=0;
data[2]=0;
data[3]=0;
if (analog2>410) data[1]=0b00000001;
if (analog2<390) data[1]=0b00001000;
if (analog2>390 && analog2<410) data[1]=0b01000000;
display.setSegments(data);
}
void Setting3() {
analog3=analogRead(A2);
Serial.println(analog3);
data[0] = 0b01011011;
data[1]=0;
data[2]=0;
data[3]=0;
if (analog3>410) data[1]=0b00000001;
if (analog3<390) data[1]=0b00001000;
if (analog3>390 && analog3<410) data[1]=0b01000000;
display.setSegments(data);
}
void ClearDisplay() {
**display.setSegments(data_clr);**
dispClear=true;
void loop() {
if (analogRead(A3)<=450) prMicros2=micros();
if (analogRead(A2)<=450) prMicros3=micros();
if (micros()-prMicros2>1500000) blocked2=true;
if (micros()-prMicros3>1500000 && !blocked2) blocked3=true;
if (blocked2) Setting2();
if (blocked3) Setting3();
if (newShot) {
ClearDisplay();
if (micros()-photocell1 > 1000000) {
if (photocell2>photocell1 && shot1==shot2) {
speedBB=(10000000*(photoDistance)/(photocell2-photocell1));
if (shot1-lastShot>4) rateFire=60000000/((photocell1-firstShot)/(shot1-lastShot));
} else err=true;
dispFlag=true;
newShot=false;
if (!err) lastShot=shot1; else {shot1=lastShot;shot2=lastShot;}
}
}
if (dispFlag && !blocked2 && !blocked3) PrintDisplay();
if (micros()-prMicrosClear>clearDisplayTime && !blocked2 && !blocked3 && !dispFlag && !dispClear) ClearDisplay();
delay(300);
}