Recent Changes - Search:

TEAMS Academy Wiki


THS0910


Explore TEAMS!
for visiting sophomores & juniors

Robotics

EnvBioTech

Bat Design

Assistive Tech

Students

Instructors

TEAMS Forum

TEAMS Calendar

TEAMS Web Site

Wiki Info

edit THS0910.SideBar

THS /

Cut & paste this simple servo program!

// Simple servo demo program

// Rhine 1/23/2010

// Definitions and Included Libraries...

#include <Servo.h>

#define GreenLED 11
#define RedLED 3
#define pressed 0 //OV on IO pin when pressed
#define not_pressed 1 //+5V on IO pin when not pressed
#define red_button 8
#define green_button 7
//Global Variable Declarations and Initialization

void setup() //"Main Program"
{
//Local Variable Declarations and Initialization

  int counter = 0;
  int timer;  // var not actually used in this brief program
  float Sharp_distance; // var not actually used in this brief program

  Servo prettyservo_9; //declare a new variable of type Servo 
  prettyservo_9.attach(9); //I'm plugging into PWM I/O pin 9 

  Serial.begin(9600); 

//Start of main program

  prettyservo_9.write(0);  // set servo to one extreme
  delay(3000);
  prettyservo_9.write(90);  // set servo to mid-point
  delay(3000);
  prettyservo_9.write(180);  // set servo to other extreme
  delay(3000);
  prettyservo_9.write(0);  
  delay(3000);
  prettyservo_9.write(180); 
  delay(3000);

  while (counter < 19)
    {
        prettyservo_9.write(counter*10);
        counter++;
        delay(500);
    }

}

void loop() {} //never use..create your own in "main"

Edit - History - Print - Recent Changes - Search
Page last modified on January 23, 2010, at 03:26 PM