Simple servo app, need a lesser board than UNO

For other supported Arduino products from Adafruit: Shields, accessories, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
airscapes
 
Posts: 52
Joined: Mon Jan 25, 2016 12:24 pm

Simple servo app, need a lesser board than UNO

Post by airscapes »

I have an UNO but it seems like a waste to use it on this simple project. I am using one digital pin to drive a servo. However I want my servo code to work as is because it works correctly.
Is there something smaller and less expensive that will run this code as is (pin can be changed and I do not need the LED) I will need it to run on 5v and do not need something with a built in regulator as it will be fed from a 5v regulator.

Code: Select all

// This sketch will operate a servo in the auto cat feeder as soon as it boots.
// The Arduino is powered on and off with an external timer and relay
// this was done to save battery power, the Arduino, External 5v regulator, and servo power 
// are all provided 12v when the timer goes off and closes the relay.  The boot and ontime of the servo
// is approximately 13 seconds, the timer on time is about 15 seconds.  A momentary push button can be
// depressed and held to provide voltage for an demand run.
    
#include <Servo.h>      // include the servo lib
Servo my_servo;         // define my server object
int ledPin = 13;        // LED connected to digital pin 13 can remove before going live
int input_value = 1;    // when power up set value

void setup()
{
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output so I know it is working with no servo
  my_servo.attach(9);          //Attach pwm signal wire to pin 9
}

void loop()
{
  // soon as powered up run 
   
  for (int cnt = 0; cnt < 18; cnt++) {
     if (input_value > 0 ) {
        digitalWrite(ledPin, input_value);
        my_servo.writeMicroseconds(1450);
        delay(250);
        
        my_servo.writeMicroseconds(1600);
        delay(350);
     }  // end if
   
  }  // end for  
  
 input_value = 0;                     // set var to 0 to stay out of for loop
 digitalWrite(ledPin, input_value);   // Turn off LED
 my_servo.writeMicroseconds(1500);    // stop servo
       
}
Last edited by airscapes on Thu Feb 04, 2016 6:18 pm, edited 1 time in total.

User avatar
adafruit_support_bill
 
Posts: 88140
Joined: Sat Feb 07, 2009 10:11 am

Re: Simple servo app, need a lesser board than UNO

Post by adafruit_support_bill »

You can drive a servo from a Trinket. You could also use a Metro Mini - that has the same processor as an UNO in a smaller and less expensive package and would require no code changes at all.

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Arduino products from Adafruit”