I'm having a problem with placement of a statement accessing a global variable. The following code generates the compiler error: " 'swSerial' does not name a type "
#include <SoftwareSerial.h>
SoftwareSerial swSerial(4, 5);
swSerial.begin(9600);
void setup() {
}
void loop() {
}
When I move the begin statement inside the setup routine, the code compiles just fine:
#include <SoftwareSerial.h>
SoftwareSerial swSerial(4, 5);
void setup() {
swSerial.begin(9600);
}
void loop() {
}
Can someone explain this to me? Thanks!