Author Topic: compiler issues  (Read 3404 times)

0 Members and 1 Guest are viewing this topic.

Offline m3vuvTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 1738
  • Country: gb
compiler issues
« on: December 13, 2020, 03:03:32 am »
hi all,im trying to load this into a uno but get these errors,any ideas what is wrong?
#include<JC_Button.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);


const float Low_BAT_level = 3.0;
//Current steps with a 3R load (R7)
const int Current [] = {0,100,200,300,400,500,600,700,800,900,1000};
const byte PWM_Pin = 10;
const byte Buzzer = 9;
const int BAT_Pin = A1;
int PWM_Value = 0;
unsigned long Capacity = 0;
int ADC_Value = 0;
float Vcc = 4.28; // Voltage of Arduino 5V pin ( Mesured by Multimeter )
float BAT_Voltage = 0;
float sample =0;
byte Hour = 0, Minute = 0, Second = 0;
bool calc = false, Done = false;
Button UP_Button(2, 25, false, true);
Button Down_Button(3, 25, false, true);


void setup () {
//
Serial.begin(9600);
pinMode(PWM_Pin, OUTPUT);
pinMode(Buzzer, OUTPUT);
analogWrite(PWM_Pin, PWM_Value);
UP_Button.begin();
Down_Button.begin();
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(2);
display.setCursor(12,25);
display.print("EASY TECH");
display.display(); 
delay(2000);
display.clearDisplay();
display.setTextSize(2);
display.setCursor(2,15);
display.print("Adj Curr:");
display.setCursor(2,40);
display.print("UP/Down:");
display.print("0");
display.display(); 
}

//************************* End of Setup function *******************************

void loop() {
  UP_Button.read();
  Down_Button.read();
if (UP_Button.wasReleased() && PWM_Value < 256 && calc == false)
 {
  PWM_Value = PWM_Value + 25;
  if(PWM_Value > 256){
    PWM_Value=PWM_Value-25;
  }
  analogWrite(PWM_Pin,PWM_Value);
  display.clearDisplay();
  display.setCursor(2,25);
  display.print("Curr:");   
  display.print(String(Current[PWM_Value / 25])+"mA");
  display.display(); 
  Serial.println(String(Current[PWM_Value / 25]));
  Serial.print(PWM_Value);
 }
if (Down_Button.wasReleased() && PWM_Value > 1 && calc == false)
{
  PWM_Value = PWM_Value - 25;
  analogWrite(PWM_Pin,PWM_Value);
  display.clearDisplay();
  display.setCursor(2,25);
  display.print("Curr:");   
  display.print(String(Current[PWM_Value / 25])+"mA");
  display.display(); 
  Serial.println(String(Current[PWM_Value / 25]) + "mA");
 
}

if (UP_Button.pressedFor (1000) && calc == false)
{
  digitalWrite(Buzzer, HIGH);
  delay(100);
  digitalWrite(Buzzer, LOW);
  display.clearDisplay();
  timerInterrupt();
   
  }
}

//************************* End of Loop function *******************************

void timerInterrupt(){
  calc = true;
  while (Done == false)  {
     Second ++;
    if (Second == 60)  {
      Second = 0;
      Minute ++;     
    }
    if (Minute == 60)  {
      Minute = 0;
      Hour ++;
    }

 //************ Measuring Battery Voltage ***********
 
  for(int i=0;i< 100;i++)
  {
   sample=sample+analogRead(BAT_Pin); //read the Battery voltage
   delay (2);
  }
  sample=sample/100;
  BAT_Voltage = sample * Vcc/ 1024.0;
 
  //*********************************************

    display.clearDisplay();
    display.setTextSize(2);
    display.setCursor(20,5);
    display.print(String(Hour) + ":" + String(Minute) + ":" + String(Second));

    display.setTextSize(1);
    display.setCursor(0,25);
    display.print("Disch Curr: ");   
    display.print(String(Current[PWM_Value / 25])+"mA");
     
   
    display.setCursor(2,40);   
    display.print("Bat Volt:" + String(BAT_Voltage)+"V" );



    Capacity =  (Hour * 3600) + (Minute * 60) + Second;
    Capacity = (Capacity * Current[PWM_Value / 25]) / 3600;
    display.setCursor(2, 55);
    display.print("Capacity:" + String(Capacity) + "mAh");
    display.display();

   
    if (BAT_Voltage < Low_BAT_level)
    {
      Capacity =  (Hour * 3600) + (Minute * 60) + Second;
      Capacity = (Capacity * Current[PWM_Value / 25]) / 3600;
      display.clearDisplay();
      display.setTextSize(2);     
      display.setCursor(2,15);     
      display.print("Capacity:");
      display.setCursor(2,40); 
      display.print(String(Capacity) + "mAh");
      display.display();
      Done = true;
      PWM_Value = 0;
      analogWrite(PWM_Pin, PWM_Value);
      digitalWrite(Buzzer, HIGH);
      delay(100);
      digitalWrite(Buzzer, LOW);
      delay(100);
      digitalWrite(Buzzer, HIGH);
      delay(100);
      digitalWrite(Buzzer, LOW);
      delay(100);
    }
       delay(1000);
  }
   
}

i get these errors:Arduino: 1.8.13 (Windows 7), Board: "Arduino Uno"





















sketch_dec13a:180:1: error: expected unqualified-id before numeric constant

 1

 ^

sketch_dec13a:371:13: error: redefinition of 'const float Low_BAT_level'

 const float Low_BAT_level = 3.0;

             ^~~~~~~~~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:13:13: note: 'const float Low_BAT_level' previously defined here

 const float Low_BAT_level = 3.0;

             ^~~~~~~~~~~~~

sketch_dec13a:373:20: error: redefinition of 'const int Current []'

 const int Current [] = {0,100,200,300,400,500,600,700,800,900,1000};

                    ^

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:15:11: note: 'const int Current [11]' previously defined here

 const int Current [] = {0,100,200,300,400,500,600,700,800,900,1000};

           ^~~~~~~

sketch_dec13a:374:12: error: redefinition of 'const byte PWM_Pin'

 const byte PWM_Pin = 10;

            ^~~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:16:12: note: 'const byte PWM_Pin' previously defined here

 const byte PWM_Pin = 10;

            ^~~~~~~

sketch_dec13a:375:12: error: redefinition of 'const byte Buzzer'

 const byte Buzzer = 9;

            ^~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:17:12: note: 'const byte Buzzer' previously defined here

 const byte Buzzer = 9;

            ^~~~~~

sketch_dec13a:376:11: error: redefinition of 'const int BAT_Pin'

 const int BAT_Pin = A1;

           ^~~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:18:11: note: 'const int BAT_Pin' previously defined here

 const int BAT_Pin = A1;

           ^~~~~~~

sketch_dec13a:377:5: error: redefinition of 'int PWM_Value'

 int PWM_Value = 0;

     ^~~~~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:19:5: note: 'int PWM_Value' previously defined here

 int PWM_Value = 0;

     ^~~~~~~~~

sketch_dec13a:378:15: error: redefinition of 'long unsigned int Capacity'

 unsigned long Capacity = 0;

               ^~~~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:20:15: note: 'long unsigned int Capacity' previously defined here

 unsigned long Capacity = 0;

               ^~~~~~~~

sketch_dec13a:379:5: error: redefinition of 'int ADC_Value'

 int ADC_Value = 0;

     ^~~~~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:21:5: note: 'int ADC_Value' previously defined here

 int ADC_Value = 0;

     ^~~~~~~~~

sketch_dec13a:380:7: error: redefinition of 'float Vcc'

 float Vcc = 4.28; // Voltage of Arduino 5V pin ( Mesured by Multimeter )

       ^~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:22:7: note: 'float Vcc' previously defined here

 float Vcc = 4.28; // Voltage of Arduino 5V pin ( Mesured by Multimeter )

       ^~~

sketch_dec13a:381:7: error: redefinition of 'float BAT_Voltage'

 float BAT_Voltage = 0;

       ^~~~~~~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:23:7: note: 'float BAT_Voltage' previously defined here

 float BAT_Voltage = 0;

       ^~~~~~~~~~~

sketch_dec13a:382:7: error: redefinition of 'float sample'

 float sample =0;

       ^~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:24:7: note: 'float sample' previously defined here

 float sample =0;

       ^~~~~~

sketch_dec13a:383:6: error: redefinition of 'byte Hour'

 byte Hour = 0, Minute = 0, Second = 0;

      ^~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:25:6: note: 'byte Hour' previously defined here

 byte Hour = 0, Minute = 0, Second = 0;

      ^~~~

sketch_dec13a:383:16: error: redefinition of 'byte Minute'

 byte Hour = 0, Minute = 0, Second = 0;

                ^~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:25:16: note: 'byte Minute' previously defined here

 byte Hour = 0, Minute = 0, Second = 0;

                ^~~~~~

sketch_dec13a:383:28: error: redefinition of 'byte Second'

 byte Hour = 0, Minute = 0, Second = 0;

                            ^~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:25:28: note: 'byte Second' previously defined here

 byte Hour = 0, Minute = 0, Second = 0;

                            ^~~~~~

sketch_dec13a:384:6: error: redefinition of 'bool calc'

 bool calc = false, Done = false;

      ^~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:26:6: note: 'bool calc' previously defined here

 bool calc = false, Done = false;

      ^~~~

sketch_dec13a:384:20: error: redefinition of 'bool Done'

 bool calc = false, Done = false;

                    ^~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:26:20: note: 'bool Done' previously defined here

 bool calc = false, Done = false;

                    ^~~~

sketch_dec13a:385:17: error: redefinition of 'Button UP_Button'

 Button UP_Button(2, 25, false, true);

                 ^

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:27:8: note: 'Button UP_Button' previously declared here

 Button UP_Button(2, 25, false, true);

        ^~~~~~~~~

sketch_dec13a:386:19: error: redefinition of 'Button Down_Button'

 Button Down_Button(3, 25, false, true);

                   ^

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:28:8: note: 'Button Down_Button' previously declared here

 Button Down_Button(3, 25, false, true);

        ^~~~~~~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino: In function 'void setup()':

sketch_dec13a:389:6: error: redefinition of 'void setup()'

 void setup () {

      ^~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:31:6: note: 'void setup()' previously defined here

 void setup () {

      ^~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino: In function 'void loop()':

sketch_dec13a:417:6: error: redefinition of 'void loop()'

 void loop() {

      ^~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:59:6: note: 'void loop()' previously defined here

 void loop() {

      ^~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino: In function 'void timerInterrupt()':

sketch_dec13a:461:6: error: redefinition of 'void timerInterrupt()'

 void timerInterrupt(){

      ^~~~~~~~~~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:103:6: note: 'void timerInterrupt()' previously defined here

 void timerInterrupt(){

      ^~~~~~~~~~~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino: In function 'void setup()':

sketch_dec13a:536:7: error: redefinition of 'void setup()'

  void setup() {

       ^~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:31:6: note: 'void setup()' previously defined here

 void setup () {

      ^~~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino: In function 'void loop()':

sketch_dec13a:541:6: error: redefinition of 'void loop()'

 void loop() {

      ^~~~

C:\Users\me\Desktop\sketch_dec13a\sketch_dec13a.ino:59:6: note: 'void loop()' previously defined here

 void loop() {

      ^~~~

exit status 1

expected unqualified-id before numeric constant



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.




 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: compiler issues
« Reply #1 on: December 13, 2020, 03:23:48 pm »
Look in the folder where the program is stored. My guess is that you have two .ini files there.

Edit: I just noticed that you posted this in different threads....and someone else also suggested that you have multiple .ini files in the folder.
« Last Edit: December 13, 2020, 03:33:06 pm by DrG »
- Invest in science - it pays big dividends. -
 

Offline ozcar

  • Frequent Contributor
  • **
  • Posts: 405
  • Country: au
Re: compiler issues
« Reply #2 on: December 13, 2020, 11:15:39 pm »
Look in the folder where the program is stored. My guess is that you have two .ini files there.

Edit: I just noticed that you posted this in different threads....and someone else also suggested that you have multiple .ini files in the folder.


Maybe you mean two .ino files?

I have not seen this in any other thread though - maybe that/those did say .ino rather than .ini.
 

Offline DrG

  • Super Contributor
  • ***
  • !
  • Posts: 1199
  • Country: us
Re: compiler issues
« Reply #3 on: December 14, 2020, 12:14:23 am »
Look in the folder where the program is stored. My guess is that you have two .ini files there.

Edit: I just noticed that you posted this in different threads....and someone else also suggested that you have multiple .ini files in the folder.


Maybe you mean two .ino files?

I have not seen this in any other thread though - maybe that/those did say .ino rather than .ini.

No, I made a typo and meant .ino file. Did you solve it yet? Did you look in the folder?
- Invest in science - it pays big dividends. -
 

Offline ozcar

  • Frequent Contributor
  • **
  • Posts: 405
  • Country: au
Re: compiler issues
« Reply #4 on: December 14, 2020, 12:50:44 am »
Look in the folder where the program is stored. My guess is that you have two .ini files there.

Edit: I just noticed that you posted this in different threads....and someone else also suggested that you have multiple .ini files in the folder.


Maybe you mean two .ino files?

I have not seen this in any other thread though - maybe that/those did say .ino rather than .ini.

No, I made a typo and meant .ino file. Did you solve it yet? Did you look in the folder?

It wasn't me with the problem.

You're probably on the right track though. Stray files with other extensions, like .pde, .c or .cpp could cause trouble too.
 

Offline m3vuvTopic starter

  • Super Contributor
  • ***
  • !
  • Posts: 1738
  • Country: gb
Re: compiler issues
« Reply #5 on: December 16, 2020, 08:41:46 pm »
sorted,the file was repeated,deleted one and bingo,cheers all.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->