IDE Blinking Led example won't compile w/Arduino as ISP

This issue is similar but different from the issue in this old posting (Dec-2011, viewed 9187 times) http://forum.arduino.cc/index.php?topic=84095.0

The same Led example compiles without errors w/Arduino as UNO. Lately I have had a strange problem with sketches that previously compiled without errors suddenly reporting errors. Suspecting a virus on my Windows system I restored an old backup made prior to my introduction to the Arduino and the errors disappeared. On the chance that it was actually my antivirus program (Malwarebytes) corrupting the system I uninstalled that last night and will wait an see if the problem went away. Just for the record, I had also backed up my sketch folder to an external non-boot drive and found that the error did not go away by restoring the sketch, suggesting that the sketch folder was also corrupted, however after restoring the boot drive and copying the same sketch from my backup folder the sketch still worked after the boot drive restore indicating that the corruption was in the OS files, not Arduino files. I did not have time to retry the ATtiny85 bootloader install procedure after restoring the boot drive but will try it tonight. I am following instructions from here: http://hlt.media.mit.edu/?p=1695

If anyone has any idea what is causing either of the above two issues I would appreciate a reply. I did see a posting somewhere to the effect that IDE ver. 1.02 would not work for this procedure but several of the other 1.0x versions would. I don't know which one I have but I'll check tonight.

After searching online I was able to find the two pieces of information necessary to successfully
program the ATtiny85 with an Arduino UNO as ISP.
Here are the two things you need to know:

  1. It doesn’t work with IDE ver 1.02
  2. Make sure you have a resistor and led connected to pin 5 of the ATtiny85 (because that is input “0” of Blink example.
  3. Make sure you change the OUTPUT pin from 13 to 0 in the Blink example.
  4. You must paste the following into the top of the IDE Blink (not Blinking Led) example:
#include <Arduino.h>
   #include <WProgram.h>

5… When you compile it you will the following message from compiler"

“Please redefine PAGEL and BS2 signals in the configuration file for the ATtiny85”

This is normal, you can ignore these.
6. Don’t forget the 10uF cap on the UNO reset pin.

I programmed two ATtiny85s and I’m playing with the examples on this link:
http://tronixstuff.com/2011/11/23/using-an-attiny-as-an-arduino/

I used these instructions to program an Attiny 45 without any problems http://hlt.media.mit.edu/?p=1695

...R

Maybe so, but I can tell for a fact that I could not without adding the #includes mentioned above and I found numerous postings outside the forum of people being advised to do that. If you have an explanation for that I would like to hear it because the instructions you cited don't mention it (that I could see).

Have you tried adding this to ArduinoAccessory.h?

#if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
#else
  #include "WProgram.h"
#endif

Here's one example . The above was from here: http://stackoverflow.com/questions/9053809/arduino-adk-android-led-blink-example-compiling-errors

?

Sorry, I must clean my PC screen -- I didn't see that you had already linked to the MIT page.

Can you post the code for the example that is causing you a problem?

I'm using version 1.0.5 of the IDE.

...R

Re: IDE Blinking Led example won't compile w/Arduino as ISP [SOLVED] « Reply #1 on: Today at 02:06:44 pm »

Four posts above I posted the solution, which some are not believing... In retrospect, I guess I should have put the "[SOLVED]" at the beginning of the line...

You must #include "WProgram.h" in your application program to gain access to the Arduino API.

This one is from the LEARNING section of this forum, here: http://playground.arduino.cc/Code/Eclipse

Not sure this is the same issue..

raschemmel: This one is from the LEARNING section of this forum, here: http://playground.arduino.cc/Code/Eclipse

I'm not sure if this is a response to my request for you to post the code for the sketch that doesn't work. In any case I can't immediately see the example on that page.

And I don't understand what that Eclipse page has to do with the MIT page?

...R

Ok Robin2, before this post gets any further out of control , let me try to get back on track.

  1. My first post was the problem, incorrectly stated as “Blinking Led example…”

  2. I found the problem and POSTED the solution, which are in my 2nd post.

  3. I did not answer your request to post the code because everyone who has the Arduino IDE
    already has the code: to wit, the “BLINK” example that comes with the IDE, NOT the "Blinking
    Led " example , which is a different (though similar) sketch altogether that comes with the IDE.
    It probably doesn’t matter that I didn’t realize I was originally using the wrong IDE example
    sketch because the correct one , the “BLINK” example also wouldn’t compile ,citing “OUTPUT
    not a declared NAME ETC.” . It also was missing the

#include <Arduino.h>
#include <WProgram.h>

  1. This is the solution I posted (now probably 6 posts ago).

  2. My last two posts were simply citing examples of other’s who have had a similar issue to
    point out that while YOU may not have had a problem programming your chips WITHOUT adding
    the above #includes , I and others were not able to get it to compile without adding those.

  3. Your probably right that the quote from the Learning section of this forum might not have been
    relevant but I included it because of the following statement:

You must #include “WProgram.h” in your application program to gain access to the Arduino API.

on the basis that perhaps this explains why I needed to add that #include and perhaps the other one too
(<Arduino.h>) because I have read somewhere that this is the replacement for WProgram.h,. I’m not sure
why you would need both instead of just one or the other.

After adding the above two #includes the “BLINK” (NOT “BLINKING LED”) IDE example compiled without errors
and the ATtiny85 began flashing the led on output (0) (pin-5). I have since run many other IDE examples
using different pins as both inputs and outputs , digital and analog. I am not sure if programming the ATtiny85
with an Arduino has any drawbacks compared to buying a USB programmer but I seemed to have a problem
loading programs that used pin-1 and pin-7 but the other pins did not interfere with loading a program.
Incidently, have you tried using Software Serial to send data to the Serial Monitor (Temp from a DS18B20 or other
data) ?

I hope this clarifies things…

Thanks for that clarification - interesting...

I have used the same blink code with my Attiny and the only modification was to change the pin from 13 to 0.

I did not have to add any #include statements. Maybe the newer IDE adds them automatically.

...R

What's strange is that I have the same veraion as you: 1.05.

I realize that this is just for academic interest now ...

I have just tried verifying my blink sketch again and it compiles without errors as an Attiny45 at 1MHz and as an Uno.

I presume you used the Attiny code from the file ATtiny-master.zip that is linked on the MIT page? I know there are other versions around but I haven't tried them.

What error did you get before you added the #includes ?

...R

I'm pretty sure I used that one and renamed the folder "ATtiny85" but I recall downloading another one from a different site named "Tiny85.zip" or "Tiny.zip". When I get back home Sunday I'll check both of them to see which one I used or if there is a difference using one vs the other by changing the filenames. On the other subject, have you tried Software Serial and what have you used your Tiny for ? Have you found any good sources for example "Tiny" programs? It's perfect for a DS18B20 application. May I assume that if it is programmed using a SPI interface (SS,SCK,MOSI,MISO) that it can be used to control SPI devices , like a SPI 6 digit 7-segment display, with the proviso that the MISO/MOSI pin functions will become swapped when the Tiny is used as a MASTER ? (are we going to get reprimanded for straying from the original topic ?)

I have only used my Attiny45 for one project so my knowledge is limited.

My project uses a TSOP 4838 IR detector to receive a serial stream from another Arduino (Uno) and if the data includes its own "address" (i.e. single byte value) it will raise the coupler for the model train wagon in which it's installed.

I am using the Attiny at 1Mhz to reduce power consumption and I wrote my own software serial code, which I would be happy to share. I was also anxious to make the code as short as I could.

I think you are correct that several SPI devices can be connected simultaneously and not interfere with each other - I guess they need separate enable lines. (Edit to add ... I'm not sure that the Atmel chips use SPI in the strict sense when programming).

Can you post a link to the SPI 7 segment display. Because of my own stupidity I now have several spare Attinys and I am thinking of making a thermometer but the displays in my "may be useful someday" bin need too many pins for an Attiny - or for my patience even with a 328.

...R

The model train application is a really cool idea. I was a big train fan as a kid. Now I only get to play with them when my wife asks me to set up her Christmas Daycare display that she uses as a backdrop for photos of the children she frames and gives to the parents, I'm researching the attiny/SPI angle and finding some several issues, (and solutions), not the least of which is that the ATtiny85 pin function in SPI mode is for SLAVE mode but some people figured how change it to MASTER. http://electronics.stackexchange.com/questions/60114/spi-h-for-attiny SPI display came from Canton Electronics ($5.99+$3.50 shipping) http://www.canton-electronics.com/arduino-6-digit-7-seg-spi-lcd-led-display-module-with-uno-mega2560-example-code-p-717.html There's a link on the right of the page to download example code but it's a *.rar file and I couldn't find an application on my wife's Mac to open it but had no problem using Winzip on my Windows PC. The example cycles through all the characters and then starts counting up to 999999 from zero incrementing 100ths of a second (or 1000ths, I can't remember which) .

I have not finished researching it but so far the issues that have to be overcome to use an ATtiny85 as a SPI master are the following: 1. Clock generation for ths SCLK signal. 2. Pin function definition to change from SLAVE to MASTER mode for the SPI function pins (mentioned above) 3. Chip select for the SS pins of the SLAVEs.

It seems I2C makes a lot more sense. I think there might be a library issue with that. I have to look into it. My next step is to get two tinys on one bus communicating with I2C/SPI/USI (whatever works). I think a tiny85/motion detector/perimeter sentry application would be a perfect fit. Each tiny monitoring a motion detector and other sensors and reporting findings to an ATmega328.

raschemmel: The model train application is a really cool idea. I was a big train fan as a kid. Now I only get to play with them ....

Christmas is coming - start writing your wishlist :)

...R

and thanks for the link, and the info about Attiny SPI.

Yeah, any day now my wife is going to tell me to get the train out of storage... Your welcome. Here's a link of I2C with the attiny: http://www.instructables.com/id/ATTiny-USI-I2C-The-detailed-in-depth-and-infor/step3/What-Is-I2C-3/