i porting my sketch from UNO to Atmega8 breadboard.
But I found one problem.
When I compilling sketch I get error about SoftwareSerial. (Is some problem with softwareserial function on Atmega8... But it is not needed in my sketch, I using sserial only for debugging).
So, software serial is forbidden via Debug function in my sketch. But why arduino compiler building software serial function, when I have commented it via debug function? Please, can you help me?
#include <avr/wdt.h>
//------------------------------------------------
//#define DEBUG // Debug ON (this switch on software serial) DEBUG 1/2 !!!!
//------------------------------------------------
#ifdef DEBUG
#include <SoftwareSerial.h>
#endif
//SoftwareSerial mySerial(11, 12); // RX, TX
// if DEBUG, MUST be uncomment DEBUG 2/2 !!!!
// -------------------------------- debug
#ifdef DEBUG
#define DBG(x) x
#define DBG_PRINT(x) mySerial.println(x)
#define DBG_PRINTnoln(x) mySerial.print(x)
#else
#define DBG(x)
#define DBG_PRINT(x)
#define DBG_PRINTnoln(x)
#endif
void setup() {
wdt_enable(WDTO_2S); // have the wdt reset the chip
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(button, INPUT_PULLUP);
// initialize serial:
Serial.begin(19200);
#ifdef DEBUG
mySerial.begin(19200);
#endif
DBG_PRINT("DBG: FUNCTION > =SETUP= is ending...");
}
In code I use this lines :
DBG_PRINT("DBG> my debug note...");
Why compiler build sotfwareserial function, when I commented DEBUG variable? Is some error in my debug function or this is arduino bug? I don´t use any softwareserial function in SETUP or LOOP. When I change line :
#include <SoftwareSerial.h>
to
#include <SoxxxareSerial.h>
Now everything is OK and builded code is shorted. So arduino use some cache of libraries or this is some bug?
Many thanks,
Petr