digitalWrite in Class

Hi,
I’m trying to use digitalWrite() in a function within a class that is separated in a *.h and a *.cpp file.
Unfortunately digitalWrite() does not work. The pin doesn’t change it’s state to HIGH.
There are no compilation errors.
I included “arduino.h” in order to be able to use digitalWrite() in my Class.cpp.

I feel like I’m missing something obvious and would like someone to give me a hint what that might be.

Regards Bastian

test.ino:

#pragma once
#include "Class.h"

#define pinEN   5

Class relais(pinEN);

void setup(){
  pinMode(pinEN,  OUTPUT);

  // Start blinking from Class  
  relais.doStuff();
}

void loop() {}

Class.cpp:

#pragma once
#include "Class.h"
#include "arduino.h"

Class::Class(bool _pinEnable) { 
  pinEnable   = _pinEnable;
}

Class::~Class() {}

void Class::doStuff(){
    digitalWrite(pinEnable, 1);
    delay(400);
    digitalWrite(pinEnable, 0);
    delay(400);
}

Class.h:

class Class
{
  public:  
    Class(bool _pinEnable);
    ~Class();
     void doStuff();
  
  private:
    bool
    pinEnable;
};

Class.cpp (275 Bytes)

Class.h (141 Bytes)

test.ino (206 Bytes)

You’ve got pinEnable declared as a bool in the class. Try using uint8_t and see if that makes a difference.

:o

Wow, how could I not see that.

Thanks for your help!