// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led_1, brightness_1);
analogWrite(led_2, brightness_2);
// change the brightness for next time through the loop:
brightness_1 = brightness_1 + fadeAmount_1;
brightness_2 = brightness_2 + fadeAmount_2;
// reverse the direction of the fading at the ends of the fade:
if (brightness_1 == 0 || brightness_1 == 255) {
fadeAmount_1 = -fadeAmount_1;
}else if (brightness_2 == 0 || brightness_2 == 255) {
fadeAmount_2 = -fadeAmount_2;
}
// wait for 90 milliseconds to see the dimming effect
delay(30);
}
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
Sorry total new, at this. A friend done this a while back, but the file was over written, managed to find what i think was a copy, but get the error. Will repost, thanks again
int led_1 = 9; // the PWM pin the LED is attached to
int led_2 = 10;
int brightness_1 = 0; // how bright the LED is
int brightness_2 = 100;
int fadeAmount_1 = 5; // how many points to fade the LED by
int fadeAmount_2 = 5;
void setup() {
pinMode(led_1, OUTPUT);
pinMode(led_2, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led_1, brightness_1);
analogWrite(led_2, brightness_2);
// change the brightness for next time through the loop:
brightness_1 = brightness_1 + fadeAmount_1;
brightness_2 = brightness_2 + fadeAmount_2;
// reverse the direction of the fading at the ends of the fade:
if (brightness_1 == 0 || brightness_1 == 255) {
fadeAmount_1 = -fadeAmount_1;
}else if (brightness_2 == 0 || brightness_2 == 255) {
fadeAmount_2 = -fadeAmount_2;
}
// wait for 90 milliseconds to see the dimming effect
delay(30);
}
int led_1 = 9; // the PWM pin the LED is attached to
int led_2 = 10;
int brightness_1 = 0; // how bright the LED is
int brightness_2 = 100;
int fadeAmount_1 = 5; // how many points to fade the LED by
int fadeAmount_2 = 5;
void setup() {
pinMode(led_1, OUTPUT);
pinMode(led_2, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 9:
analogWrite(led_1, brightness_1);
analogWrite(led_2, brightness_2);
// change the brightness for next time through the loop:
brightness_1 = brightness_1 + fadeAmount_1;
brightness_2 = brightness_2 + fadeAmount_2;
// reverse the direction of the fading at the ends of the fade:
if (brightness_1 == 0 || brightness_1 == 255) {
fadeAmount_1 = -fadeAmount_1;
} else if (brightness_2 == 0 || brightness_2 == 255) {
fadeAmount_2 = -fadeAmount_2;
}
// wait for 90 milliseconds to see the dimming effect
delay(30);
}
It compiles for me for a UNO on 2.3.2 IDE.
I copied it to notebook++, then selected and copied it to the IDE.
Your copy may have some hidden characters, copying to notebook may wash them away.
The unwashed still compiled okay in 1.8.19 and 2.3.2
Hey much appreciation for testing thank you so much. Strange, tried latest version, of IDE and 1.8.1, have 4 copies with different names, same error. Thanks again
If you had originally posted the full error message then the cause of the problem would have been more obvious because the location of where setup() was originally defined would have been obvious
As it was, @david_2018, @sterretje and I had to rely on our spidey senses to guess the cause of the problem. It is almost as though we had seen it before ...