user14917: I am trying to use a class in .ino file. The code is:
  .ino file
#include <LED.h>

int Pin1 = 13;
int Pin2 = 12;
int Pin3 = 11;
LED led;
void setup() {
  pinMode(Pin1,OUTPUT);
  pinMode(Pin2,OUTPUT);
  pinMode(Pin3,OUTPUT);
  digitalWrite(Pin1,LOW);
  digitalWrite(Pin2,LOW);
  digitalWrite(Pin3,LOW);
}

void loop() {
  led.on(Pin1);
  delay(2);
  led.on(Pin2);
  delay(2);
  led.on(Pin3);
  delay(2);
}

.h file
#ifndef LED_h
#define LED_h

class LED{
public:
    void on(int);
    void off(int);
};

#endif

.cpp file
#include <stdio.h>
#include <Arduino.h>
#include "LED.h"    

void LED::on(int PIN){
    digitalWrite(PIN,HIGH);
}

void LED::off(int PIN){
    digitalWrite(PIN,LOW);
}

Arduino compiler picks the object declaration error:
LEDC:6: error: 'LED' does not name a type
LEDC.ino: In function 'void loop()':
LEDC:17: error: 'led' was not declared in this scope
How should I declare objects in Arduino then?
The way that I am putting the files in folders is like the attached image:


user4143: That version of the IDE (it seems to change from version to version) differentiates between includes with <...> and includes with "...".
If you use <...> it only looks in the system and library areas.  If you use "..." it also looks inside your sketch.
So in your main INO file change the LED include from:
#include <LED.h>

To:
#include "LED.h"

and it should compile.

14917: <p>I am trying to use a class in .ino file. The code is:
 <br/><br/> .ino file</p>

<pre><code>#include &lt;LED.h&gt;

int Pin1 = 13;
int Pin2 = 12;
int Pin3 = 11;
LED led;
void setup() {
  pinMode(Pin1,OUTPUT);
  pinMode(Pin2,OUTPUT);
  pinMode(Pin3,OUTPUT);
  digitalWrite(Pin1,LOW);
  digitalWrite(Pin2,LOW);
  digitalWrite(Pin3,LOW);
}

void loop() {
  led.on(Pin1);
  delay(2);
  led.on(Pin2);
  delay(2);
  led.on(Pin3);
  delay(2);
}
</code></pre>

<p>.h file</p>

<pre><code>#ifndef LED_h
#define LED_h

class LED{
public:
    void on(int);
    void off(int);
};

#endif
</code></pre>

<p>.cpp file</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;Arduino.h&gt;
#include "LED.h"    

void LED::on(int PIN){
    digitalWrite(PIN,HIGH);
}

void LED::off(int PIN){
    digitalWrite(PIN,LOW);
}
</code></pre>

<p>Arduino compiler picks the object declaration error:</p>

<p>LEDC:6: error: 'LED' does not name a type<br/>
LEDC.ino: In function 'void loop()':<br/>
LEDC:17: error: 'led' was not declared in this scope<br/></p>

<p>How should I declare objects in Arduino then?<br/></p>

<p>The way that I am putting the files in folders is like the attached image:</p>

<p><a href="https://i.stack.imgur.com/aPIEJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aPIEJ.png" alt="enter image description here"></a></p>
 4143: <p>That version of the IDE (it seems to change from version to version) differentiates between includes with <code>&lt;...&gt;</code> and includes with <code>"..."</code>.</p>

<p>If you use <code>&lt;...&gt;</code> it only looks in the system and library areas.  If you use <code>"..."</code> it also looks inside your sketch.</p>

<p>So in your main INO file change the LED include from:</p>

<pre><code>#include &lt;LED.h&gt;
</code></pre>

<p>To:</p>

<pre><code>#include "LED.h"
</code></pre>

<p>and it should compile.</p>
