I have some arduino code that i want to put on a atiny2313 as the arduino is overkill, in fact the the atiny2313 is more then i need but i have some to use. it consist of two button that turn a pin high and low to control an mp3 player. here is the arduino code.
first of all pinMode, digitalWrite & digitalRead are arduino api functions and won't be available when programming the attiny2313 in c. digital pin 7 on an arduino is pin7 of the atmega168's PORTD. on the attiny2313 PORTD has only 7 pins, numbered 0-6.
your arduino code doesn't do any debouncing of the inputs. you may get away with it since you have lengthy delays in your input processing but sooner or later your player's going to turn on in response to some random electronic noise.
Port the arduino libraries to ATtiny2313
Write functions approximately similar to the Adruino ones, for the tiny, from scratch.
Write a program from scratch that does the same thing overall, without using Arduino-like functions.
I think I'd rate all three as approximately equivalent in difficulty, all rather educational, and probably all a bit beyond someone who had the ask the question in the first place (sorry...)
A better approach may be to figure out how to take the programmed ATmega168 chip out of the arduino after its been programmed, and operate it in "stand alone" mode. Replace the one in the arduino and continue to use the full arduino as the development environment. This, at least, is well documented and explained in various places on the arduino site. An ATmega168 is not THAT much more expensive than an ATtiny2313, even if you get the mega with the arduino already built in. You're looking at a $2.50 chip vs a $5.50 chip; shipping costs may dominate.
That was my fall back solution, I've been having some much trouble just getting simple code onto the 2313. I feel using the 168 would be better. I just have to figure out how to get the bootloader onto the chips. the source code is on the arduino site but that's not the problems I've been having, i keep getting held up on the stupid makefiles.
tge1986 wrote:That was my fall back solution, I've been having some much trouble just getting simple code onto the 2313. I feel using the 168 would be better. I just have to figure out how to get the bootloader onto the chips. the source code is on the arduino site but that's not the problems I've been having, i keep getting held up on the stupid makefiles.
If you have a plain old '168 then you dont "have" to put the bootloader on the chip...
You can make it so that the arduino IDE uses a programmer instead of the bootloader...
tge1986 wrote:That was my fall back solution, I've been having some much trouble just getting simple code onto the 2313. I feel using the 168 would be better. I just have to figure out how to get the bootloader onto the chips. the source code is on the arduino site but that's not the problems I've been having, i keep getting held up on the stupid makefiles.
If you have a plain old '168 then you dont "have" to put the bootloader on the chip...
You can make it so that the arduino IDE uses a programmer instead of the bootloader...
As a relative n00b to microcontrollers, the arduino's been a great way to get into it, but I'd like to move onto other processors, namely the ATtiny13 or the ATMega32, but I do like the Arduino environment.
So what it sounds like I need to do if I want to stay inside the Arduino IDE, I'd have to write a library specifically for each chip?