6

FOllowing on from this question, I'm following the tutorial for programming an ATtiny45 using an arduino.

Using v0021 of the Arduino IDE, with a Duemilanove which i've replaced the 168 chip with a 328, I'm able to upload the ArduinoISP sketch correctly. However, trying to upload the blink sketch to the Attiny results in the following error:

ArduinoISP.cpp: In function 'void setup()':
ArduinoISP.cpp:79: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void loop()':
ArduinoISP.cpp:136: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'uint8_t getch()':
ArduinoISP.cpp:142: error: 'Serial' was not declared in this scope
ArduinoISP.cpp:143: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void readbytes(int)':
ArduinoISP.cpp:147: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void spi_init()':
ArduinoISP.cpp:164: error: 'SPCR' was not declared in this scope
ArduinoISP.cpp:165: error: 'SPSR' was not declared in this scope
ArduinoISP.cpp:166: error: 'SPDR' was not declared in this scope
ArduinoISP.cpp: In function 'void spi_wait()':
ArduinoISP.cpp:172: error: 'SPSR' was not declared in this scope
ArduinoISP.cpp:172: error: 'SPIF' was not declared in this scope
ArduinoISP.cpp: In function 'uint8_t spi_send(uint8_t)':
ArduinoISP.cpp:177: error: 'SPDR' was not declared in this scope
ArduinoISP.cpp: In function 'void empty_reply()':
ArduinoISP.cpp:194: error: 'Serial' was not declared in this scope
ArduinoISP.cpp:198: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void breply(uint8_t)':
ArduinoISP.cpp:204: error: 'Serial' was not declared in this scope
ArduinoISP.cpp:209: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void start_pmode()':
ArduinoISP.cpp:263: error: 'SS' was not declared in this scope
ArduinoISP.cpp:265: error: 'SCK' was not declared in this scope
ArduinoISP.cpp:270: error: 'MISO' was not declared in this scope
ArduinoISP.cpp:271: error: 'MOSI' was not declared in this scope
ArduinoISP.cpp: In function 'void end_pmode()':
ArduinoISP.cpp:277: error: 'MISO' was not declared in this scope
ArduinoISP.cpp:278: error: 'MOSI' was not declared in this scope
ArduinoISP.cpp:279: error: 'SCK' was not declared in this scope
ArduinoISP.cpp:280: error: 'SS' was not declared in this scope
ArduinoISP.cpp: In function 'void program_page()':
ArduinoISP.cpp:348: error: 'Serial' was not declared in this scope
ArduinoISP.cpp:356: error: 'Serial' was not declared in this scope
ArduinoISP.cpp:362: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'char flash_read_page(int)':
ArduinoISP.cpp:375: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'char eeprom_read_page(int)':
ArduinoISP.cpp:387: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void read_page()':
ArduinoISP.cpp:397: error: 'Serial' was not declared in this scope
ArduinoISP.cpp:400: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void read_signature()':
ArduinoISP.cpp:409: error: 'Serial' was not declared in this scope
ArduinoISP.cpp:412: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'int avrisp()':
ArduinoISP.cpp:436: error: 'Serial' was not declared in this scope
ArduinoISP.cpp:497: error: 'Serial' was not declared in this scope

How can I fix this please? Or does anyone know if it works with a previous version of the IDE?

fearoffours
  • 548
  • 2
  • 7
  • 13
  • 1
    Why is there no code included in this question? – Bort Feb 14 '17 at 14:17
  • 2
    **The very premise of this question statement is wrong.** Quite obviously, the errors are in the ISP sketch, *not* the blink sketch. Perhaps your actual problem is that you are accidentally trying to build the ISP sketch (which should run on the ATmega you are using as a programmer) for the target ATtiny, rather than build the target blink sketch for the target. – Chris Stratton Feb 14 '17 at 15:22
  • Same problem: I am using Visual Studio with Visual Micro and Arduino1.8 IDE. Solved by creating a completely blank project and copy/paste the whole code. Then, I was able to Build and Upload my code to an ATtiny85 with no problem. Never could figure out what the cause of the problem was. – Fred Cailloux Apr 01 '19 at 19:58

3 Answers3

3

For anyone coming after me, I ran into this problem, but no mention of SoftwareSerial was indicated. Rather (I know it sounds crazy) the answer was on this thread of the Arduino forums:

Throw some dummy code at the very top of your sketch (yes, even before includes). Mine:

char foo;
JellicleCat
  • 649
  • 1
  • 8
  • 18
3

Doh fixed it myself. Needed to include the SoftwareSerial library in the updated blink sketch. That piece of info is missing from the tutorial linked above.

fearoffours
  • 548
  • 2
  • 7
  • 13
2

You need to include the SoftwareSerial Library in your updated sketch. In order to do this, go to the Sketch menu and scroll down through "Import Library..." to the SoftwareSerial Library, selecting it to add it.

Alternatively, add #include <SoftwareSerial.h> to the top of your sketch, the above does the same thing.

user391339
  • 473
  • 7
  • 17