Show Posts
Pages: 1 ... 11 12 [13]
181  Forum 2005-2010 (read only) / Interfacing / Re: Multiple servo code help on: July 05, 2010, 05:14:06 pm
Wait so how do u use the servo libary do u go to examples in the arduono program or what
182  Forum 2005-2010 (read only) / Interfacing / Re: Multiple servo code help on: July 05, 2010, 01:30:50 pm
alright so could u maby show me for 2 servos so i get the main idea. this is the main code that i want five times but if you could help me do it to it would be very helpful:


Code:
/*
 Servo control from an analog input

The minimum (minPulse) and maxiumum (maxPulse) values
will be different depending on your specific servo motor.
Ideally, it should be between 1 and 2 milliseconds, but in practice,
0.5 - 2.5 milliseconds works well for me.
Try different values to see what numbers are best for you.

This program uses the millis() function to keep track of when the servo was
last pulsed.  millis() produces an overflow error (i.e. generates a number
that's too big to fit in a long variable) after about 5 days. if you're
making a program that has to run for more than 5 days, you may need to
account for this.

by Tom Igoe
additions by Carlyn Maw & Rob Faludi
Created 28 Jan. 2006
Updated 10 Jun. 2008
*/

int servoPin = 2;     // Control pin for servo motor
int minPulse = 500;   // Minimum servo position
int maxPulse = 2500;  // Maximum servo position
int pulse = 0;        // Amount to pulse the servo

long lastPulse = 0;    // the time in milliseconds of the last pulse
int refreshTime = 20; // the time needed in between pulses

int analogValue = 0;  // the value returned from the analog sensor
int analogPin = 0;    // the analog pin that the sensor's on

void setup() {
 pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin
 pulse = minPulse;           // Set the motor position value to the minimum
 Serial.begin(9600);
}

void loop() {
 analogValue = analogRead(analogPin);      // read the analog input
 pulse = map(analogValue,0,1023,minPulse,maxPulse);    // convert the analog value
                                                       // to a range between minPulse
                                                       // and maxPulse.

 // pulse the servo again if rhe refresh time (20 ms) have passed:
 if (millis() - lastPulse >= refreshTime) {
   digitalWrite(servoPin, HIGH);   // Turn the motor on
   delayMicroseconds(pulse);       // Length of the pulse sets the motor position
   digitalWrite(servoPin, LOW);    // Turn the motor off
   lastPulse = millis();           // save the time of the last pulse
 }
}
183  Forum 2005-2010 (read only) / Interfacing / Multiple servo code help on: July 05, 2010, 12:07:39 pm
Alright so I have 5 flex sensors and 5 servos I have a code for 1 flex to controll 1 servo but I need a code that will have 1 flex controll 1 servo fir 5 of each
184  Forum 2005-2010 (read only) / Interfacing / Re: Best multiplexer on: July 06, 2010, 12:53:10 am
Dam that's a lot and a lot of code dude the biggest one I no is the mega arduino and that's nit even 104
185  Forum 2005-2010 (read only) / Interfacing / Running 5 servos with arduino? on: July 05, 2010, 07:39:03 pm
is it possible to run 5 servos with a single arduino?
186  Forum 2005-2010 (read only) / Interfacing / Re: Arduino Flex sensor help (ergent) on: July 04, 2010, 11:37:38 am
alright so i got that too i just changed the 1023 to a 0 and the 0 to a 500 and here is my final code:


/*
  Servo control from an analog input

 The minimum (minPulse) and maxiumum (maxPulse) values
 will be different depending on your specific servo motor.
 Ideally, it should be between 1 and 2 milliseconds, but in practice,
 0.5 - 2.5 milliseconds works well for me.
 Try different values to see what numbers are best for you.

 This program uses the millis() function to keep track of when the servo was
 last pulsed.  millis() produces an overflow error (i.e. generates a number
 that's too big to fit in a long variable) after about 5 days. if you're
 making a program that has to run for more than 5 days, you may need to
 account for this.

 by Tom Igoe
 additions by Carlyn Maw & Rob Faludi
 Created 28 Jan. 2006
 Updated 10 Jun. 2008
 */

 int servoPin = 2;     // Control pin for servo motor
 int minPulse = 500 ;   // Minimum servo position
 int maxPulse = 4000;  // Maximum servo position
 int pulse = 0;        // Amount to pulse the servo

 long lastPulse = 0;    // the time in milliseconds of the last pulse
 int refreshTime = 20; // the time needed in between pulses

 int analogValue = 0;  // the value returned from the analog sensor
 int analogPin = 0;    // the analog pin that the sensor's on

 void setup() {
  pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin
  pulse = minPulse;           // Set the motor position value to the minimum
  Serial.begin(9600);
 }

 void loop() {
  analogValue = analogRead(analogPin);      // read the analog input
  pulse = map(analogValue,500,0 ,minPulse,maxPulse);    // convert the analog value
                                                        // to a range between minPulse
                                                        // and maxPulse.

  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin, HIGH);   // Turn the motor on
    delayMicroseconds(pulse);       // Length of the pulse sets the motor position
    digitalWrite(servoPin, LOW);    // Turn the motor off
    lastPulse = millis();           // save the time of the last pulse
  }
 }
 
187  Forum 2005-2010 (read only) / Interfacing / Re: Arduino Flex sensor help (ergent) on: July 04, 2010, 11:33:19 am
alright so i pretty much got it working but when i flex the sensor about 90 degrees it does the maximum servo command adn i want it around 180 degrees you have to flex it
188  Forum 2005-2010 (read only) / Interfacing / Re: Arduino Flex sensor help (ergent) on: July 04, 2010, 11:29:56 am
alright so what i got is for the
flex sensor: 500-200
presure sensor:0-950
189  Forum 2005-2010 (read only) / Interfacing / Re: Arduino Flex sensor help (ergent) on: July 04, 2010, 11:11:59 am
alright so the link u gave me about the map()... like idk what to do from here because i do have the map() in my code but its confusing with the variables but how do u want me to do this if u were me find he esistance through a multimeter ot what
190  Forum 2005-2010 (read only) / Interfacing / Re: Arduino Flex sensor help (ergent) on: July 04, 2010, 10:50:23 am
Alright i noticed i do have a map function in the code above but could u maby give me just a sample code to play with and get it fined tuned that controlles a servo

thank you
191  Forum 2005-2010 (read only) / Interfacing / Re: Arduino Flex sensor help (urgent) on: July 04, 2010, 12:52:21 am
Alright so if I could post a link I would and it would be a lot easier tell me prob. Alright so I have built a circuit with a presure sensor so the harder u press the more the servo will rotate. Then I tried putting a flex sensor in an it dosnt seem to work at all it turn less then 90degrees. So maby I have the code wron or maby the wrong resistor I jut don't know


Thank you
192  Forum 2005-2010 (read only) / Interfacing / Arduino Flex sensor help (ergent) on: July 03, 2010, 08:06:13 pm
Alright so i have an arduino and a servo and a flex sensor i have tried out code with a presure censor:

 /*
  Servo control from an analog input

 The minimum (minPulse) and maxiumum (maxPulse) values
 will be different depending on your specific servo motor.
 Ideally, it should be between 1 and 2 milliseconds, but in practice,
 0.5 - 2.5 milliseconds works well for me.
 Try different values to see what numbers are best for you.

 This program uses the millis() function to keep track of when the servo was
 last pulsed.  millis() produces an overflow error (i.e. generates a number
 that's too big to fit in a long variable) after about 5 days. if you're
 making a program that has to run for more than 5 days, you may need to
 account for this.

 by Tom Igoe
 additions by Carlyn Maw & Rob Faludi
 Created 28 Jan. 2006
 Updated 10 Jun. 2008
 */

 int servoPin = 2;     // Control pin for servo motor
 int minPulse = 500;   // Minimum servo position
 int maxPulse = 2500;  // Maximum servo position
 int pulse = 0;        // Amount to pulse the servo

 long lastPulse = 0;    // the time in milliseconds of the last pulse
 int refreshTime = 20; // the time needed in between pulses

 int analogValue = 0;  // the value returned from the analog sensor
 int analogPin = 0;    // the analog pin that the sensor's on

 void setup() {
  pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin
  pulse = minPulse;           // Set the motor position value to the minimum
  Serial.begin(9600);
 }

 void loop() {
  analogValue = analogRead(analogPin);      // read the analog input
  pulse = map(analogValue,0,1023,minPulse,maxPulse);    // convert the analog value
                                                        // to a range between minPulse
                                                        // and maxPulse.

  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin, HIGH);   // Turn the motor on
    delayMicroseconds(pulse);       // Length of the pulse sets the motor position
    digitalWrite(servoPin, LOW);    // Turn the motor off
    lastPulse = millis();           // save the time of the last pulse
  }
 }




i have built that and when i replaced the presure sensor i got from sparkfun it only turns the servo less then 90 degrees when i have the presure sensor on it turn the maximum of 180 degrees

please i really need your help and fast thank you
193  Forum 2005-2010 (read only) / Exhibition / Re: Keyglove one-handed input device on: October 08, 2010, 11:23:39 pm
hey this is reallly cool im doing somthing similar right now. i made an animatronic hand controlled by servos and am currently working on the glove you wear wich has flex sencors in it. its for science fair for my school and its wireless with 2 xbee moguiles. but thats cool i would love to hear more baout the kind of sensors you use and all that stuff
Pages: 1 ... 11 12 [13]