A simple example with a class

Could someone help me make a very simple class?

Here is a simplified example. Notice the error the first time the object is used.


class myClass{
    int pin;
    int value;

myClass c;
c.pin = D0; // error: 'c' does not name a type
c.value = 1;

void setup() {
    pinMode(c.pin, OUTPUT)

void loop() {
    digitalWrite(c.pin, c.value);
    c.value = !c.value;

Try moving your

c.pin = D0;
c.value = 1;

inside your setup() function and let me know if that works for you

1 Like

That worked! Thank you!

1 Like