I am a noobie. . .
My initial sketch worked pretty well on an Arduino Uno R3 (ELEGOO).
I made the code more adaptable to what I want and I started seeing some odd chars in the print statements, so I switched over to an Arduino R2 (Arduino)
Now I've switched back to my Arduino Uno R3 (ELEGOO) and I cannot get this very basic
program to load.
Is there something I need to change other than the BOARD and the COM port ?
Anything in the setup section shows "Out of Scope"
I'm guessing something easy, that I just cannot see, or something about the environment that I do not understand.
I could use some help !
Below is my code, sort of the first step after "Hello World" for Arduino.
//LED_Ramp_OutOfScopeError_InSetup
// Define Pins
#define GREEN 3
// define variables
// #include <SoftwareSerial.h>
int greenValue=0;
void setup()
{
pinMode(GREEN, OUTPUT);
// Getting error: "'OUTPUT' was not declared in this scope"
// Whatever command comes first in the setup gives an out of scope error
// Initially I had Serial.begin (9600) as the first line and it gave an out of scope error also
digitalWrite(GREEN, LOW);
Serial.begin(9600); //Allows serial monitor-Print statements
}
// main loop
void loop()
{
#define delayTime 10 // fading time between steps
greenValue = 0; // set a value between 1 and 255 to change the brightness.
for(int i = 0; i < 255; i += 1)
{
greenValue += 1;
analogWrite(GREEN, greenValue);
delay(delayTime);
}
greenValue = 255; //Should already be at 255
for(int i = 0; i < 255; i += 1)
{
greenValue -= 1;
analogWrite(GREEN, greenValue);
delay(delayTime);
}
}
Please post the error messages you see. Above and to the right of the area of the IDE where the error messages appear, you should see a "copy error messages" button. Click that, then hit reply, click "</>" and paste the error messages.
This does not sound like an installation/troubleshooting problem, it sounds like a coding problem. If I'm right, I will move your topic to a more suitable section of the forum.
Below is the error message I am getting.
Blockquote
Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno"
sketch\RGB_LED_by_ELEGOO.cpp: In function 'void setup()':
RGB_LED_by_ELEGOO.cpp:12:18: error: 'OUTPUT' was not declared in this scope
pinMode(GREEN, OUTPUT);
^~~~~~
RGB_LED_by_ELEGOO.cpp:12:3: error: 'pinMode' was not declared in this scope
pinMode(GREEN, OUTPUT);
^~~~~~~
RGB_LED_by_ELEGOO.cpp:16:23: error: 'LOW' was not declared in this scope
digitalWrite(GREEN, LOW);
^~~
RGB_LED_by_ELEGOO.cpp:16:3: error: 'digitalWrite' was not declared in this scope
digitalWrite(GREEN, LOW);
^~~~~~~~~~~~
RGB_LED_by_ELEGOO.cpp:17:3: error: 'Serial' was not declared in this scope
Serial.begin(9600); //Allows serial monitor-Print statements
^~~~~~
sketch\RGB_LED_by_ELEGOO.cpp: In function 'void loop()':
RGB_LED_by_ELEGOO.cpp:30:3: error: 'analogWrite' was not declared in this scope
analogWrite(GREEN, greenValue);
^~~~~~~~~~~
RGB_LED_by_ELEGOO.cpp:31:3: error: 'delay' was not declared in this scope
delay(delayTime);
^~~~~
RGB_LED_by_ELEGOO.cpp:38:3: error: 'analogWrite' was not declared in this scope
analogWrite(GREEN, greenValue);
^~~~~~~~~~~
RGB_LED_by_ELEGOO.cpp:39:3: error: 'delay' was not declared in this scope
delay(delayTime);
^~~~~
exit status 1
'OUTPUT' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Hmm, Looks like I had two tabs of sketches in the IDE.
I had one file in the folder that was a .ino file, and another with a different name that was a .cpp.
I deleted the .cpp file, and now it compiles ok.
Seems like that fixed my problem.
The two programs were about the same, but had different names.
Can you please mark the most helpful post as the solution? This prevents helpers spending time on a solved issue and it will lead people with the same question to the correct answer directly.
Your topic has been moved to a more suitable location on the forum Installation and Troubleshooting is not for problems with (nor for advice on) your project.