I get the error "PB5 was not declared in this scope". This is my code:
#define LED PB5 // LED is on Pin 13 or Pin 5 of Port B
int main(void) {
for(;;) {
PORTB |= (1 << LED);
}
return 0; // never reached
}
What is the problem? Thanks.
I get the error "PB5 was not declared in this scope". This is my code:
#define LED PB5 // LED is on Pin 13 or Pin 5 of Port B
int main(void) {
for(;;) {
PORTB |= (1 << LED);
}
return 0; // never reached
}
What is the problem? Thanks.
What is the problem? Thanks.
It says right there:
"PB5 was not declared in this scope".
But I do write:
#define LED PB5
How could I fix it? Thanks.
#define PB5 5
#define LED PB5
#define LED 5 would be shorter
#define LED PB5
That defines LED as PB5 but it doesn't define PB5, which is what your compiler is complaining about.
PB5 should already be defined as '5' through Arduino.h, which gets added automatically to all sketches. Arduino.h actually includes the files like io.h, ioxxxx.h, which actually defines PB5 as 5 and portpins.h, which defines PORTB5 as PB5.
Mister_Transistor:
PB5 should already be defined as '5' through Arduino.h, which gets added automatically to all sketches.
Might that depend on the IDE version?
OP's code compiles without error on my system. How are you compiling it? is it in a library? Are you using a non-arduino toolchain?
The correct symbol is "PORTB5" not "PB5".
Either deliberately or by mistake some AVR Libc versions also include the symbol "PB5".