Programming Error

Greetings,

I am an avid model railroader and was just introduced to Arduino several weeks ago and already I can see endless applications for Arduino in this hobby.
My background in electronics is in DCC (Digital Command Control) and making simple electronic circuits to create animation on the train layout. I have no background in programming.
This is my first attempt at writing a sketch. It is supposed to imitate an arc welder by flashing a white ultra bright and a blue led randomly then when the flashing stops a red led led glows brightly then dims and dies out and after a delay it will repeat the process five more times. Please note that this is part of a larger sketch. The original included infra red sensing for activation and a number of building lights to come on, none of which fit my needs.
I have run into a program error on my last line of the sketch that I thought would be an easy fix but because of my limited knowledge I can't seem to fix it. While I have pursed Arduino's programming error's site and have found error codes similar to mine I haven't found one that fixes my problem so I am in hopes that someone can assist me in solving this error.
I am using an Arduino UNO clone board and I have pasted the code along with code tags in its entirety and have included the actual error code as well:

int ledWhite = 2;
int ledglowPin = 3;
int ledBlue = 4;
int sequence_starter = 0;
int wait = 1000;
int count;
int welder_count = 6;


void setup() {
  // put your setup code here, to run once:
  pinMode (ledWhite, OUTPUT);
  pinMode (ledglowPin, OUTPUT);
  pinMode (ledBlue, OUTPUT);


}


void loop() {
  // put your main code here, to run repeatedly:
  welder (); {
  }


} void welder () {
  count = random(10, 60);
  for (int i = 0; i < count; i++);
  {
    digitalWrite(ledWhite, HIGH);
    delay (random (60));
    digitalWrite (ledWhite, LOW);
    delay (random(200));
    digitalWrite (ledBlue, HIGH);
    delay (random (10));
    digitalWrite (ledBlue, LOW);
    delay (random (100));




    //Glow starts after arc flashing ends and then slowly dies out


    for (int j = 50; j > 1; j--) {
      analogWrite (ledglowPin, j);
      { delay (100);
      }
      delay (random(800, 2000));
    }
int ledWhite = 2;
int ledglowPin = 3;
int ledBlue = 4;
int sequence_starter = 0;
int wait = 1000;
int count;
int welder_count = 6;


void setup() {
  // put your setup code here, to run once:
  pinMode (ledWhite, OUTPUT);
  pinMode (ledglowPin, OUTPUT);
  pinMode (ledBlue, OUTPUT);


}


void loop() {
  // put your main code here, to run repeatedly:
  welder (); {
  }


} void welder () {
  count = random(10, 60);
  for (int i = 0; i < count; i++);
  {
    digitalWrite(ledWhite, HIGH);
    delay (random (60));
    digitalWrite (ledWhite, LOW);
    delay (random(200));
    digitalWrite (ledBlue, HIGH);
    delay (random (10));
    digitalWrite (ledBlue, LOW);
    delay (random (100));




    //Glow starts after arc flashing ends and then slowly dies out


    for (int j = 50; j > 1; j--) {
      analogWrite (ledglowPin, j);
      { delay (100);
      }
      delay (random(800, 2000));
    }


Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"


C:\Users\jack\AppData\Local\Temp\arduino_modified_sketch_530125\BareMinimum.ino: In function 'void welder()':


BareMinimum:43:5: error: expected '}' at end of input


     }


    


exit status 1


expected '}' at end of input






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

Respectfully Submitted,
Warbonnet

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

C:\Users\jack\AppData\Local\Temp\arduino_modified_sketch_530125\BareMinimum.ino: In function 'void welder()':

BareMinimum:43:5: error: expected '}' at end of input

}

^

BareMinimum:43:5: error: expected '}' at end of input

exit status 1

expected '}' at end of input

Topic moved

@warbonnet - the Website and Forum section was the wrong place to post this

} void welder ()
{
  count = random(10, 60);

The welder() function end too soon, don't you think ?

  welder (); {

Stray {

} void welder () {

Stray }

  for (int i = 0; i < count; i++);
  {

Stray ;

There are probably others, not looked any further.

I suggest you read more about the correct use of syntax in C/C++ as you seem to not really get it. Plenty of information on this site and other sites with tutorials about C/C++

The real problem is that the welder() function is missing its closing } and so is its first for loop

If you Auto Format the code in the IDE then all functions should start and end on the left margin. Your welder() function doesn't

Bob,
Yes, I see what you mean. Two additional }} and it compiles, however, the for loop won't work because of the stray ; (like we usually see with if).

OP,
For me the the important lesson for you is that keeping the code tidy and carefully following the syntax rules is really, really important. Perhaps you have an annoying friend who is always pulling you up on the slightest grammatical error (I have), well in human languages getting your mords wuddled doesn't usually impact the meaning too much, in computer languages a single misplaced character will wreck your code, and the compiler won't always indicate the correct place to look.

To both Bob and Perry,

I thank you both for responding and sharing your insight with me. As I had mentioned in my original post I am new to this whole process and was overly anxious to see this program work so I jumped in with both feet instead of first learning the proper protocol for writing a sketch. And Perry, I will heed your advice and bone up on syntax c/c++ and clean up this program and try it again.
Again gentlemen, thank you for your thoughts and suggestions.

Jack (warbonnet)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.