On my Due i have the following code (Arduino IDE 1.5.2). It should force pin 8 to HIGH, but pin 8 will be LOW instead.
// THIS DOES NOT WORK ON THE DUE, PIN 8 WILL BE LOW
class pin {
public:
pin() {
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
}
int z;
};
class pin x;
void setup() {
x.z++;
}
void loop() {
}
If I put the constructor call into the setup(), it will work. So this is fine and pin 8 will be HIGH:
class pin {
public:
pin() {
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
}
int z;
};
void setup() {
class pin x;
x.z++;
}
void loop() {
}
On the Uno, both examples produce HIGH at pin 8.
Any ideas? Did I miss something? I had looked into this forum, but did not see any thead about this topic.
Unfortunately this currently breaks my library: During the constructor call a do a low active reset on an external device. Of course i expect, that the output pin stays HIGH within setup() and loop(). But this is not true and my external device will be put into reset again.