arduino is overkill... can i use ATtiny45 instead?

hey guys… total beginner here… got my arduino uno and did some basic experimenting… but the more i read/research, the more i realize i may do fine with ATtiny45… but confirmation from some experts would be great!.. with that said, here’s the relevant portion of my sketch:

void loop()
{
  press = digitalRead(button);
  if (press == LOW)
  {
    if(toggle)
    {
      myServo.writeMicroseconds(1700);  // Counter clockwise
      delay(10000);                      // Wait 2 seconds
      myServo.writeMicroseconds(1500);  // Stop 
      toggle = !toggle;
    }
    else
    {
      myServo.writeMicroseconds(1300);  // Clockwise
      delay(2000);          // Wait 2 seconds
      myServo.writeMicroseconds(1500);  // Stop 
      toggle = !toggle;
    }
  }
  delay(200);  //delay for debounce

so my question is this - can this be accomplished with a ATtiny45 (using arduino as a programmer)?

any and all guidance would be greatly appreciated!..

  • max

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

Use a Atmega 328 purchased for $4.00 plus crystal caps a resistors in a standalone version.
You can then run the same code the UNO can.

That servo library will not work on Attiny45.
A while ago I too tried to control a servo with Attiny and came across (i believe) this » ATtiny45/85 Servo Library Cunning Turtle

However, I had issues with certain models of servo. One would work OK, the other acted unpredictably.
That being said it certainly can work depending on the servo you pick.

I have used this servo library with both Attiny85 and 2313 and different servos without any issues

http://forum.arduino.cc/index.php?topic=198337.msg1463365#msg1463365

thank you! all of your replies are very helpful as i try to wrap my head around this task (i know it's probably super-basic for most but as i said, this is brand new to me)...

just so that i understand this correctly - is there a downside to using Atmega328 even if it's "overkill" when Attiny45 would suffice?.. is it only the cost? (i assume Atmega328 costs a bit more?)... obviously if that's the only drawback, i'm happy to live with it to avoid the extra steps that Attiny45 involves...

thank you again!..

  • max

No downside at all. Easiest would be to use an Arduino Nano. They are quite reasonable in price. I bought some on eBay from China.. 3 for about $12.50

They use the 328.

LarryD:
Use a Atmega 328 purchased for $4.00 plus crystal caps a resistors in a standalone version.
You can then run the same code the UNO can.

Why not use the 328P internal oscillator? Then no crystal (or it's glue) is needed.

And, an Arduino UNO with a ZIF socket installed would make a really neat platform for development. Start with a 328P with a bootloader, write and compile to your heart's content, then burn the final version in with "#define F_CPU 8000000" in the source and use AVRDUDE to change the fuses to internal oscillator.

Bingo, standalone controller.