Using this code, I get the following error


int LEDpin = 2;  // connect MIC pin 4 to Arduino pin 2

void setup() 
{
  pinMode(LEDpin, OUTPUT);  // Tells the arduino which pin is used
}

int Cycle = 0;
While (Cycle < 10) 
{
  if (cycle < 9) 
  {
    digitalWrite(LEDpin, HIGH);    // Turn the LED on
    Serial.println("LED IS ON");   // display text to verify led is on
    delay(1000);                   // Wait for 1 second
    digitalWrite(LEDpin, LOW);     // Turn the LED off
    Serial.println("LED IS OFF");  // display text to verify led is off
    delay(500);                    // Wait for .5 second
  } 
  else 
  {
    digitalWrite(LEDpin, HIGH);  // Turn the LED on
    delay(2000);                 // Wait for 2 second
    digitalWrite(LEDpin, LOW);   // Turn the LED off
    delay(500);                  // Wait for .5 second
  }
  cycle = cycle + 1;
}

***> Blockquote***

here is the error message

C:\Users\mbanks\Documents\Arduino\MOSFET_LED\MOSFET_LED.ino:9:7: error: expected constructor, destructor, or type conversion before '(' token
While (Cycle != 10) {
^

exit status 1

Compilation error: expected constructor, destructor, or type conversion before '(' token

Capitalisation counts 'while'.

while with lower case 'w'

with the lowercase while I get the following error message.

C:\Users\mbanks\Documents\Arduino\MOSFET_LED\MOSFET_LED.ino:10:1: error: expected unqualified-id before 'while'
while (Cycle < 10)
^~~~~

exit status 1

Compilation error: expected unqualified-id before 'while'

You're missing a loop() function. The whole block after the setup() function should be in a function (e.g. loop())

that was it thank you.

So you fixed Cycle vs. cycle too?

And added

  Serial.begin(115200);

to the setup() function?

a7, with help from chatGPT…

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