Go Down

Topic: 'PORTD' was not declared in this scope (Read 209 times) previous topic - next topic

ajherch

I am currently writing a code to produce a tone on a NodeMCU and I keep getting an error message saying 'PORTD' was not declared in this scope  and I cant figure out how to fix it. Here's my code.

void setup(){
     pinMode(D3,OUTPUT);
}

void loop(){
     playNote(568);
     delay(250);
}

void playNote(int noteDelay){
     int x;
     for(x=0;x<100000/noteDelay;x++){
     PORTD |=0x01;
     delayMicroseconds(noteDelay);
     PORTD &=0xFE;
     delayMicroseconds(noteDelay);
     }
}

TheMemberFormerlyKnownAsAWOL

You're trying to compile code for a processor that doesn't have a PORTD.
Please don't PM technical questions - post them on the forum, then everyone benefits/suffers equally

westfw

PORTD is an AVR thing.  NodeMCU has an ESP8266, on which "direct port IO" is different.

Go Up