Arduino translated to AVR?

Hello! I have some arduino code that I have written, and I am curious how that could be translated to work with an 8-pin AVR IC, such as the attiny85v or something similar. I am assuming I would be using AVRdude or some similar program. I know that the 2 languages are similar, so I am wondering:

How would I know if my arduino program would be able to fit on an AVR IC?
How could I check the size of the program in comparison to the limits of the AVR?

Is there a translator program, or a reference source that would specify the major differences between the two languages?
That I would understand what I needed to modify in order for it to work with AVRdude.

Are there any potential disadvantages to look out for?

If I could translate the Arduino code to work with a smaller, more compact and cheaper IC, than it seems logical to pursue this route.

I've searched around for ways to translate the code, but haven't been able to find an article that directly relates to these questions.

Thanks in advance for your advice.

http://www.google.com/search?q=arduino+attiny85

You're probably interested in the very first link. Tells how to adapt the IDE for the tiny and then how to program it using an existing Arduino.

That's it. I kept searching for 'translate arduino to avr' and things similar to that, and had no luck. I hadn't tried those specific search terms, but that's exactly what i'm looking for! thank you!

I've followed the steps according to http://hlt.media.mit.edu/?p=1229

I am using an Arduino UNO with the Arduino software version 0022, and the instructions state as follows:

-Download: attiny45_85.zip
-Locate your Arduino sketchbook folder (you can find its location in the preferences dialog in the Arduino software)
-Create a new sub-folder called “hardware” in the sketchbook folder.
-Copy the attiny45_85 folder from the attiny45_85.zip to the hardware folder.
-Restart the Arduino development environment.

Then the sketch should be uploaded via “ATtiny45 (w/ Arduino as ISP)” or “ATtiny85 (w/ Arduino as ISP)” from the Tools > Board menu.

The ATtiny 45/85v option is not available under the tools > board menu, and I doublechecked to make sure the hardware folder and its subcontents were placed correctly, and the program fully closed/restarted.

Any ideas why this may be?

I always put things in the

blah/Arduino/Hardware/Arduino/

folders where arduino is installed (its old and I am stubborn)

there you will find things like boards.txt and a folder for cores (put the core files in its own folder under cores)

for me I have better luck training a drunken monkey to shoot a riffle than getting the includes to work outside of where every thing else is based from ... course I am special like that (and honestly believe trying to make things easier just makes things worse)

You will have better luck with this core...
http://code.google.com/p/arduino-tiny/

The 45_85 core has a few bugs and is missing some features.

Assuming you are using Windows, after expanding either core, your directory structure should be similar this where your sketches are stored in [u]C:\Projects\Arduino\Sketch[/u]

C:\Projects\Arduino\Sketch\hardware\tiny\boards.txt
C:\Projects\Arduino\Sketch\hardware\tiny\cores
C:\Projects\Arduino\Sketch\hardware\tiny\cores\empty
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny
C:\Projects\Arduino\Sketch\hardware\tiny\cores\empty\Arduino.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\empty\main.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\empty\WProgram.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\Arduino.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\binary.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\core_adc.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\core_build_options.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\core_macros.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\core_pins.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\core_timers.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\HardwareSerial.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\HardwareSerial.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\main.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\pins_arduino.c
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\pins_arduino.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\Print.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\Print.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\PwmTimer.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\Stream.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\TinyDebugSerial.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\TinyDebugSerial.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\TinyDebugSerial115200.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\TinyDebugSerial38400.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\TinyDebugSerial9600.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\TinyDebugSerialErrors.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\Tone.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\ToneTimer.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\UserTimer.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\WCharacter.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\WConstants.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\WInterrupts.c
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\wiring.c
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\wiring.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\wiring_analog.c
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\wiring_digital.c
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\wiring_private.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\wiring_pulse.c
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\wiring_shift.c
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\WMath.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\WProgram.h
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\WString.cpp
C:\Projects\Arduino\Sketch\hardware\tiny\cores\tiny\WString.h

If you have the patience there is monstrous topic here about the Tiny Core and programming ATtiny processors the Arduino Way...
http://arduino.cc/forum/index.php/topic,51984.0.html

The download is for Arudino 1.0
I am using version 0022.

I am on a Mac btw...should've mentioned that earlier

I went ahead and added the files I downloaded for the 1.0, and it worked! The Attiny IC's are listed under the board options.
I uploaded the sketch for using the Arduino as an ISP,
I then opened the Blink sketch and changed the pinout to pin 0 insead of pin 13,
inserted a capacitor between reset and GND, and tried to upload it with all of the attiny85v options available,
and none of them worked.

they all stated:
avrdude: stk500_recv(): programmer is not responding

any ideas?

What size capacitor?

Drc3p0:

[quote author=Coding Badly link=topic=108797.msg817188#msg817188 date=1338960878]

You will have better luck with this core...
Google Code Archive - Long-term storage for Google Code Project Hosting.

The 45_85 core has a few bugs and is missing some features.

The download is for Arudino 1.0
I am using version 0022.

I am on a Mac btw...should've mentioned that earlier
[/quote]

+1 on Google Code Archive - Long-term storage for Google Code Project Hosting.

You will find better help and support for it. Consider upgrading Arduino, 0022 is getting fairly dated.

Best Regards,
George

I've been holding off, since I originally had issues with UNO and 1.0

Is there a clear solution for any issues that may arise with this upgrade and UNO? If so, then i am more than happy to download it. I just didn't want to spend a lot of time trying to solve any issues that may arise, as I ended up doing the first time I tried it.

I was using a 47uF capacitor. I know that it states 10, but I haven't had any issues with the capacitor size being too large. I've successfully bootloaded/uploaded sketches to ATMEGA328 IC's. Its just the new breed of attiny's that i'm having issues with.

Drc3p0:
Is there a clear solution for any issues that may arise with this upgrade and UNO?

I have both versions installed (0022 and 1.0.1). I have only encountered one annoyance: Arduino 1.0x changes the filename extension when a sketch is saved. That behaviour can be disabled under File / Preferences.

Serial changed considerably. If you rely on Serial being "blocking" stick with 0022.

Drc3p0:
I was using a 47uF capacitor. I know that it states 10, but I haven't had any issues with the capacitor size being too large.

Yeah that should be fine. I use the same size.

Connect an LED + current limiting resistor to pin 9. When uploading: at all times the LED on pin 9 should display a "heartbeat" and the LED on pin 13 should never light. Is that what happens?

Please post the verbose output from an upload attempt.

Well great, now when I tried to verify the ArduinoISP sketch to my Uno, i recieve several error messages. The proper board and serial port were chosen. This is all happeneing after I added those attiny core files into the 'hardware' folder, as instructed before. I may have placed them in the wrong folder or something, but I now recieve these error messages:

I'm going to go ahead and switch to 1.0 before continuing....

ArduinoISP.cpp: In function 'void setup()':
ArduinoISP:48: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void loop()':
ArduinoISP:105: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'uint8_t getch()':
ArduinoISP:111: error: 'Serial' was not declared in this scope
ArduinoISP:112: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void readbytes(int)':
ArduinoISP:116: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void empty_reply()':
ArduinoISP:163: error: 'Serial' was not declared in this scope
ArduinoISP:167: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void breply(uint8_t)':
ArduinoISP:173: error: 'Serial' was not declared in this scope
ArduinoISP:178: error: 'Serial' was not declared in this scope
ArduinoISP.cpp: In function 'void start_pmode()':
ArduinoISP:232: error: 'SS' was not declared in this scope
ArduinoISP:234: error: 'SCK' was not declared in this scope
ArduinoISP:239: error: 'MISO' was not declared in this scope
ArduinoISP:240: error: 'MOSI' was not declared in this scope
ArduinoISP.cpp: In function 'void end_pmode()':
ArduinoISP:246: error: 'MISO' was not declared in this scope

AND THE LIST GOES ON....

I have upgraded a step to Arduino 1.0
I downloaded the atiny zip and placed it in the 'hardware' folder within the sketchbook. from Google Code Archive - Long-term storage for Google Code Project Hosting.
The instructions state that there should be an option for 'Atiny85v (with Arduino as ISP)'
That option is not available, and I couldn't get any of the 85v options to upload successfully. Here are the options that I have available:

Why is it that I don't have the same board options that the instructions indicate?

Why is it that I don't have the same board options that the instructions indicate?

The names used in the Tiny Core are just a bit different and a bit more descriptive than the names used in the HLT core. The Tiny Core is correctly installed.

At this point you should be able to select any of the ATtiny85 entries, perform a Tools / Burn Bootloader in the IDE, and have a processor configured and ready to use. I suggest starting with the 8 MHz entry: ATtiny85 @ 8 MHz (internal oscillator; BOD disabled).

That option is not available, and I couldn't get any of the 85v options to upload successfully.

Error message?

I tried to burn the bootloader, with these options:

Board > attiny85v @ 8 MHz (internal oscillator, BOD disabled)
Programmer > Arduino as ISP
selected 'Burn Bootloader'

recieved this as the error message:

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x14

avrdude: stk500_getparm(): (a) protocol error, expect=0x14, resp=0x01
avrdude: stk500_initialize(): (a) protocol error, expect=0x14, resp=0x10
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

avrdude: stk500_disable(): unknown response=0x12

When you perform the Burn Bootloader, does the LED on pin 13 ever blink? Does the LED on pin always display a heartbeat?