"ledBlink" was not declared in this scope

im new to arduino and especially platformio. When I build my program it fails and gives me the error message, “” was not declared in this scope. Why is that?

#include <Arduino.h>

const int led = 6;

void setup() 

{

  pinMode(led, OUTPUT);

}

void loop() 

{

  ledBlink();

}

void ledBlink()

{

    digitalWrite(led, HIGH);

  delay(500);

  digitalWrite(led, LOW);

  delay(500);

}

You are calling into a function before declaring it – the C++ compiler has no idea what ledBlink() is if it can’t see the function declaration or definition beforehand. This is a difference in Arduino .ino files and actual pure .cpp files. See the FAQ on how to do the conversion.

1 Like