i am working on a project ,that is to include a arduino uno or mega ,a 24 volt dc motor drive (from electric cart) the drive unit has a analog 5k pot . wiper center is neutral and =2.5volts dc ,also any positive voltage above 2.5 - 5.0 v dc is forward and 2.4- 0 v dc .is reverse and both are variable speed . 2.5 v dc also energizes a brake on the motor . so i tried to use a mcp4261 digital pot . Did get it to drive . i am not good with programming enough to get it to work well . so i made a bracket that holds a servo that drives the 5k pot i use the example servo sweep. i was able to play with the delays and degree of steps. what i would like to learn how to map this with a aultrasonic sensor. any help in guiding me to the right places to learn i one year into trying to lean what i can about programming the arduino boards . i have long background in electronics and machine control . plcs. and ladder programs . very little c++.
Some servo test code.
//zoomkat 3-5-12 simple delimited ',' string parse
//from serial port input (via serial monitor)
//and print result out serial port
String readString;
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
Serial.begin(9600);
myservo.writeMicroseconds(1500); //set initial servo position if desired
myservo.attach(7); //the pin for the servo control
Serial.println("servo-delomit-test-22-dual-input"); // so I can keep track of what is loaded
}
void loop() {
//expect a string like 700, or 1500, or 2000,
//or like 30, or 90, or 180,
if (Serial.available()) {
char c = Serial.read(); //gets one byte from serial buffer
if (c == ',') {
if (readString.length() >0) {
Serial.println(readString); //prints string to serial port out
int n = readString.toInt(); //convert readString into a number
// auto select appropriate value, copied from someone elses code.
if(n >= 500)
{
Serial.print("writing Microseconds: ");
Serial.println(n);
myservo.writeMicroseconds(n);
}
else
{
Serial.print("writing Angle: ");
Serial.println(n);
myservo.write(n);
}
//do stuff with the captured readString
readString=""; //clears variable for new input
}
}
else {
readString += c; //makes the string readString
}
}
}
I was with you right up until you introduced the ultrasonic sensor. What do you propose this sensor will do? What are you sensing with it?
I suggest you get the digital potentiometer to work,
Write a short program to adjust the pot and use analogRead() to detect the voltage on the wiper. If it does not work we can help with your program.
...R
i did get the digital pot to work over night and it works great . i added some code to get ping to automate its is working how I want now and I will post the code shortly, I have to workout how to get the unit to turn. This is going to be a cart that will follows me around with my Snapon tool box at work. so the sensor is just so it wont hint any thing I also have that part figured out how to use voice commands for say locking tool box . ill just start there .