Notifications
Clear all

Trouble with the IDE unknown problem

14 Posts
4 Users
0 Reactions
416 Views
(@quince)
Member
Joined: 2 years ago
Posts: 40
Topic starter  

A few days ago I tried to install a library for the AT tiny85 and lost internet connection sometime during the process. The result is my IDE is finding things that I cannot locate, and so will not compile any new code. I have included a copy of the last try to compile a code that looks clean to me. stray"#" in code at stalldelay line 9  is  the exit message from the compiler . I have clean the cashes and restarted with no luck.  Any ideas as to cause and repair would be appreciated. Thanks, Quince

[code]
1 // Include necessary libraries for communication and sensor
2 #include <Wire.h>
3 #include <Adafruit_INA260.h>
4
5 // Define constant values for relay, enable pin, loop delay, stall delay, and button release delay
6 #define RELAYPIN 9
7 #define ENABLEPIN 8
8 #define LOOPDELAY 50
9 #define STALLDELAY 100
10 #define BUTTON_RELEASE_DELAY 5000 // 5 seconds delay after button release
11
12 // Create an instance of the INA260 sensor
13 Adafruit_INA260 ina260 = Adafruit_INA260();
14 // Declare a variable to store the current reading from the sensor
15 float current;
16 // Declare a variable to remember the last time the button was released
17 unsigned long lastButtonReleaseTime = 0;
18
19 // Setup function - runs once when the Arduino is powered on or reset
20 void setup() {
21 // Begin serial communication at a baud rate of 115200
22 Serial.begin(115200);
23 // Wait for the serial port to be ready
24 while (!Serial)
25 delay(10);
26 // Print a starting message on the serial monitor
27 Serial.println("Adafruit INA260 Test");
28 // Set the relay pin as an OUTPUT
29 pinMode(RELAYPIN, OUTPUT);
30 // Initially set the relay to OFF (LOW)
31 digitalWrite(RELAYPIN, LOW);
32 // Set the enable pin (connected to the SPST switch) as an INPUT with internal pull-up resistor
33 pinMode(ENABLEPIN, INPUT_PULLUP);
34 // Initialize the INA260 sensor and check if it's connected
35 if (!ina260.begin()) {
36 // If sensor is not found, print an error message
37 Serial.println("Couldn't find INA260 chip");
38 // Infinite loop to stop further execution
39 while (1);
40 } else
41 // If sensor is found, print a success message
42 Serial.println("Found INA260 chip");
43 }
44
45 // Main loop function - runs continuously after the setup() function
46 void loop() {
47 // Check if the enable switch (SPST) is pressed (connected to ground)
48 if (digitalRead(ENABLEPIN) == LOW) {
49 // Update the last pressed time when the button is pressed
50 lastButtonReleaseTime = millis();
51 // Read the current value from the INA260 sensor
52 current = ina260.readCurrent();
53 // Print the current value to the serial monitor
54 Serial.print("Current: ");
55 Serial.print(current);
56 Serial.println(" mA");
57 // If the current is less than 2000mA (2A), activate the relay
58 if (current < 2000) {
59 Serial.println("Activating relay");
60 digitalWrite(RELAYPIN, HIGH);
61 }
62 // If the current exceeds 5000mA (5A), deactivate the relay for safety
63 if (current > 5000) {
64 Serial.println("Deactivating relay due to overcurrent");
65 digitalWrite(RELAYPIN, LOW);
66 // Wait for the stall delay (time to protect the circuit) before turning on the relay again
67 delay(STALLDELAY);
68 digitalWrite(RELAYPIN, HIGH);
69 }
70 } else {
71 // Check if the elapsed time since the last button release exceeds the defined delay
72 if (millis() - lastButtonReleaseTime >= BUTTON_RELEASE_DELAY) {
73 // If it exceeds, deactivate the relay
74 digitalWrite(RELAYPIN, LOW);
75 // Print a message to the serial monitor indicating the system is disabled
76 Serial.println("System disabled due to button release delay");
77 }
78 }
79 // Wait for the loop delay before the next iteration of the loop
80 delay(LOOPDELAY);
81 }
[/code]

 error: stray '#' in program

^~

exit status 1

stray '#' in program

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


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@quince I don't see the stray #. Second do as the compiler told you, turn on verbose. Next post, read the help on the right side of the screen re posting code.

Firest, reinstall whatever you were doing when you lost internet.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2542
 

Posted by: @quince

 error: stray '#' in program

Because you're not posting the code in proper format, we can't compile your sketch. But a possible cause is the comment in line ...

#define BUTTON_RELEASE_DELAY 5000 // 5 seconds delay after button release

Try removing the comment section and try it again.

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@quince Remove the comment on line 10

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
(@quince)
Member
Joined: 2 years ago
Posts: 40
Topic starter  

Sorry for the incorrect format. i have not used the site in awhile. I tried deleting the comment at line 10 with no luck. I have gone into board manager and deleted any reference to the download and cleared the cashe.

[code]
1   // Include necessary libraries for communication and sensor
2   #include <Wire.h>
3   #include <Adafruit_INA260.h>
4   
5   // Define constant values for relay, enable pin, loop delay, stall delay, and button release delay
6   #define RELAYPIN 9
7   #define ENABLEPIN 8
8   #define LOOPDELAY 50
9   #define STALLDELAY 100
10  #define BUTTON_RELEASE_DELAY 5000 
11  
12  // Create an instance of the INA260 sensor
13  Adafruit_INA260 ina260 = Adafruit_INA260();
14  // Declare a variable to store the current reading from the sensor
15  float current;
16  // Declare a variable to remember the last time the button was released
17  unsigned long lastButtonReleaseTime = 0;
18  
19  // Setup function - runs once when the Arduino is powered on or reset
20  void setup() {
21      // Begin serial communication at a baud rate of 115200
22      Serial.begin(115200);
23      // Wait for the serial port to be ready
24      while (!Serial)
25          delay(10);
26      // Print a starting message on the serial monitor
27      Serial.println("Adafruit INA260 Test");
28      // Set the relay pin as an OUTPUT
29      pinMode(RELAYPIN, OUTPUT);
30      // Initially set the relay to OFF (LOW)
31      digitalWrite(RELAYPIN, LOW);
32      // Set the enable pin (connected to the SPST switch) as an INPUT with internal pull-up resistor
33      pinMode(ENABLEPIN, INPUT_PULLUP);
34      // Initialize the INA260 sensor and check if it's connected
35      if (!ina260.begin()) {
36          // If sensor is not found, print an error message
37          Serial.println("Couldn't find INA260 chip");
38          // Infinite loop to stop further execution
39          while (1);
40      } else
41          // If sensor is found, print a success message
42          Serial.println("Found INA260 chip");
43  }
44  
45  // Main loop function - runs continuously after the setup() function
46  void loop() {
47      // Check if the enable switch (SPST) is pressed (connected to ground)
48      if (digitalRead(ENABLEPIN) == LOW) {
49          // Update the last pressed time when the button is pressed
50          lastButtonReleaseTime = millis();
51          // Read the current value from the INA260 sensor
52          current = ina260.readCurrent();
53          // Print the current value to the serial monitor
54          Serial.print("Current: ");
55          Serial.print(current);
56          Serial.println(" mA");
57          // If the current is less than 2000mA (2A), activate the relay
58          if (current < 2000) {
59              Serial.println("Activating relay");
60              digitalWrite(RELAYPIN, HIGH);
61          }
62          // If the current exceeds 5000mA (5A), deactivate the relay for safety
63          if (current > 5000) {
64              Serial.println("Deactivating relay due to overcurrent");
65              digitalWrite(RELAYPIN, LOW);
66              // Wait for the stall delay (time to protect the circuit) before turning on the relay again
67              delay(STALLDELAY);
68              digitalWrite(RELAYPIN, HIGH);
69          }
70      } else {
71          // Check if the elapsed time since the last button release exceeds the defined delay
72          if (millis() - lastButtonReleaseTime >= BUTTON_RELEASE_DELAY) { 
73              // If it exceeds, deactivate the relay
74              digitalWrite(RELAYPIN, LOW);
75              // Print a message to the serial monitor indicating the system is disabled
76              Serial.println("System disabled due to button release delay"); 
77          }
78      }
79      // Wait for the loop delay before the next iteration of the loop
80      delay(LOOPDELAY);
81  }
[/code]

 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@quince Show us the error. No idea what you are talking about re cache. Have NEVER done that, don't know how.

Did you re-install the board after you 'deleted' it?

I am very concerned with your choice e of words, there is NO delete, there is a 'REMOVE' option.

I just tried to copy the code so I can try to compile it but I CAN'T because there are line numbers in the source code.

Post the code again, without any line numbers.

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2542
 

@quince 

It's not going to compile with the line numbers in the code. Please post the sketch correctly. Compiled clean for me (compiled for MEGA).

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@quince It appears you scraped the code from a web page. That is not how it is done.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Rob_1967
(@rob_1967)
Member
Joined: 10 months ago
Posts: 5
 

Ron was there a copy write on the code? Just curious....

I wrote a quick script to remove the line numbers is you are still interested in debugging it.

  // Include necessary libraries for communication and sensor
  #include <Wire.h>
  #include <Adafruit_INA260.h>
  
  // Define constant values for relay, enable pin, loop delay, stall delay, and button release delay
  #define RELAYPIN 9
  #define ENABLEPIN 8
  #define LOOPDELAY 50
  #define STALLDELAY 100
  #define BUTTON_RELEASE_DELAY 5000 
  
  // Create an instance of the INA260 sensor
  Adafruit_INA260 ina260 = Adafruit_INA260();
  // Declare a variable to store the current reading from the sensor
  float current;
  // Declare a variable to remember the last time the button was released
  unsigned long lastButtonReleaseTime = 0;
  
  // Setup function - runs once when the Arduino is powered on or reset
  void setup() {
      // Begin serial communication at a baud rate of 115200
      Serial.begin(115200);
      // Wait for the serial port to be ready
      while (!Serial)
          delay(10);
      // Print a starting message on the serial monitor
      Serial.println("Adafruit INA260 Test");
      // Set the relay pin as an OUTPUT
      pinMode(RELAYPIN, OUTPUT);
      // Initially set the relay to OFF (LOW)
      digitalWrite(RELAYPIN, LOW);
      // Set the enable pin (connected to the SPST switch) as an INPUT with internal pull-up resistor
      pinMode(ENABLEPIN, INPUT_PULLUP);
      // Initialize the INA260 sensor and check if it's connected
      if (!ina260.begin()) {
          // If sensor is not found, print an error message
          Serial.println("Couldn't find INA260 chip");
          // Infinite loop to stop further execution
          while (1);
      } else
          // If sensor is found, print a success message
          Serial.println("Found INA260 chip");
  }
  
  // Main loop function - runs continuously after the setup() function
  void loop() {
      // Check if the enable switch (SPST) is pressed (connected to ground)
      if (digitalRead(ENABLEPIN) == LOW) {
          // Update the last pressed time when the button is pressed
          lastButtonReleaseTime = millis();
          // Read the current value from the INA260 sensor
          current = ina260.readCurrent();
          // Print the current value to the serial monitor
          Serial.print("Current: ");
          Serial.print(current);
          Serial.println(" mA");
          // If the current is less than 2000mA (2A), activate the relay
          if (current < 2000) {
              Serial.println("Activating relay");
              digitalWrite(RELAYPIN, HIGH);
          }
          // If the current exceeds 5000mA (5A), deactivate the relay for safety
          if (current > 5000) {
              Serial.println("Deactivating relay due to overcurrent");
              digitalWrite(RELAYPIN, LOW);
              // Wait for the stall delay (time to protect the circuit) before turning on the relay again
              delay(STALLDELAY);
              digitalWrite(RELAYPIN, HIGH);
          }
      } else {
          // Check if the elapsed time since the last button release exceeds the defined delay
          if (millis() - lastButtonReleaseTime >= BUTTON_RELEASE_DELAY) { 
              // If it exceeds, deactivate the relay
              digitalWrite(RELAYPIN, LOW);
              // Print a message to the serial monitor indicating the system is disabled
              Serial.println("System disabled due to button release delay"); 
          }
      }
      // Wait for the loop delay before the next iteration of the loop
      delay(LOOPDELAY);
  }

An expert is a person who has made all the mistakes that can be made in a very narrow field.” - Niels Bohr.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@rob_1967 Not sure what you mean by

was there a copy write on the code

nothing to debug, it compiles. Not a surprise since it was copied from somewhere else.

 

 

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2542
 

Posted by: @zander

@rob_1967 Not sure what you mean by

was there a copy write on the code

He probably means copyright.

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@will Copyright? What the heck has that got to do with anything? As a former professional photographer, I can tell you copyright does not work the way you think mostly it provides no protection other than to scare the occasional ignorant person. It is extremely difficult to enforce, and honest lawyers will tell you it isn't worth it.

So why is Copyright being mentioned here?

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2542
 

@zander 

Whoa, I didn't say it applied; I was just pointing out that it's a homonym for "copy write", also "copy rite" and "cop pee right". I'm not suggesting that any of those alternatives apply either 🙂

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 4 years ago
Posts: 7140
 

@will 😀

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
My personal scorecard is now 1 PC hardware fix (circa 1982), 1 open source fix (at age 82), and 2 zero day bugs in a major OS.


   
ReplyQuote