View Single Post
  #10   Spotlight this post!  
Unread 17-01-2013, 13:19
tr6scott's Avatar
tr6scott tr6scott is offline
Um, I smell Motor!
AKA: Scott McBride
FRC #2137 (TORC)
Team Role: Mentor
 
Join Date: Dec 2007
Rookie Year: 2005
Location: Oxford, MI
Posts: 508
tr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond reputetr6scott has a reputation beyond repute
Re: CIM->Victor 884->Arduino not working

This is working code, I have two pots, one is set only goes one direction, the other pot goes full rev -> 0 -> full forward. This was hacked together a couple of years ago, and put in an Altoids can, we are using it to prototype again this year.

Code:
#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
Servo myservo1;  // create servo object to control a servo 
 
int potpin = 0;  // pot in is 13 pwm analog pin used to connect the potentiometer
int potpin1 = 1;  // analog pin used to connect the potentiometerint val;    // variable to read the value from the analog pin 
int val =0;
int val1=0;
void setup() 
{ 
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
 myservo1.attach(10);  // attaches the servo on pin 9 to the servo object 
} 
 
void loop() 
{ 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) //
  val1 = analogRead(potpin1);            // reads the value of the potentiometer (value between 0 and 1023) 
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180) 
  val1 = map(val1, 0, 1023, 90, 179);     // scale it to use it with the servo (value between 0 and 180) 
   myservo.write(val);                  // pwm 13 sets the servo position according to the scaled value 
   myservo1.write(val1);                  // sets the servo position according to the scaled value 
  delay(15);                           // waits for the servo to get there 
}
__________________
The sooner we get behind schedule, the more time we have to catch up.