6
\$\begingroup\$

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?

\$\endgroup\$

closed as unclear what you're asking by Chris Stratton, Voltage Spike, Wesley Lee, uint128_t, ThreePhaseEel Feb 16 '17 at 3:29

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ Why is there no code included in this question? \$\endgroup\$ – Bort Feb 14 '17 at 14:17
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Chris Stratton Feb 14 '17 at 15:22
  • \$\begingroup\$ 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. \$\endgroup\$ – Fred Cailloux Apr 1 at 19:58
3
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ If it's fixed, please close the question. \$\endgroup\$ – Toby Jaffey Oct 8 '10 at 10:19
  • 4
    \$\begingroup\$ @Joby self answered questions cannot be marked as accepted by the OP for 2 days \$\endgroup\$ – fearoffours Oct 8 '10 at 10:40
  • 1
    \$\begingroup\$ Well, I've learnt something new today. \$\endgroup\$ – Toby Jaffey Oct 8 '10 at 11:50
  • 1
    \$\begingroup\$ can you be more specific in your answer? how did you include the softwareserial library in your sketch? \$\endgroup\$ – user391339 Dec 30 '14 at 19:15
  • \$\begingroup\$ This answer is incorrect. The actual issue appears to arise from mixing up the ISP sketch for the ATmega with the blink sketch for the ATtiny. \$\endgroup\$ – Chris Stratton Feb 14 '17 at 15:28
3
\$\begingroup\$

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;
\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.