Recent Posts

Pages: 1 2 3 ... 10
Software / Re: Sharp IR Sensor with arduino
« Last post by jwatte on Yesterday at 06:49:15 PM »
value will be between 0 and 1023 for the range of 0..5V. A value of 2V is approximately 410. You are testing against "2".
Software / Re: Sharp IR Sensor with arduino
« Last post by Cheetofingers on Yesterday at 01:01:15 PM »
okay, maybe there is something wrong with my hardware now. I think the code should be good....

It is not reading the voltage like it should be.  when I have the code to set the motors to run when it reads above 2 voltage it always runs even when i have my IR sensor pointed far away where the voltage should be less than 2. 

Here is what the code looks like now, made it easier to read too.

const int motor1Pin1 = 3;    // H-bridge leg 1 (pin 2, 1A)
const int motor1Pin2 = 4;    // H-bridge leg 2 (pin 7, 2A)
const int motor2Pin1 = 5;
const int motor2Pin2 = 6;
const int enablePin1 = 9;    // H-bridge enable pin
const int enablePin2 = 10;
int sensorpin = 0;
double value;
void setup()
    pinMode(motor1Pin1, OUTPUT);
    pinMode(motor1Pin2, OUTPUT);
    pinMode(motor2Pin1, OUTPUT);
    pinMode(motor2Pin2, OUTPUT);
    pinMode(enablePin1, OUTPUT);
    pinMode(enablePin2, OUTPUT);
  void loop()
    double value;
    value1 = analogRead(sensorpin);
    if (value > 2)
      digitalWrite(enablePin1, HIGH);
      digitalWrite(enablePin2, HIGH);
      digitalWrite(motor1Pin1, LOW);   // set leg 1 of the H-bridge low
      digitalWrite(motor1Pin2, HIGH);  // set leg 2 of the H-bridge high
      digitalWrite(motor2Pin1, LOW);
      digitalWrite(motor2Pin2, HIGH);
      digitalWrite(enablePin1, LOW);
      digitalWrite(enablePin2, LOW);
Use the same design as a XY plotter with the button locations mapped in memory. Then put a solinoid in place as your button pusher. This is assuming only one button will ever be pushed at a time.
Stepper motors can be used to move the solinoid from one button location to another.

Just my two cents...
Mechanics and Construction / Re: Please help me build a robot for my kitten
« Last post by Titanium69 on Yesterday at 10:40:06 AM »
I think you should stick with a stepper motor. Once a claw is snagged in the target, you will want the power for the target to be pulled free. A servo may not have to torque.

It may be a good idea to monitor the current being pulled by the motor, so in case of a serious snag, the controller will just give up for a few seconds rather than over heat your motor and/or drain your batteries.

Just my two cents...
Software / Re: Sharp IR Sensor with arduino
« Last post by Cheetofingers on April 19, 2014, 07:43:31 PM »
oh wow i see now, i set the voltage to high in the setup, so it doesn't know to return to that voltage in loop function. So obvious.

going to try it soon, thanks!

Software / Re: Sharp IR Sensor with arduino
« Last post by jwatte on April 19, 2014, 02:40:58 PM »
Your loop() code never turns the enable pin high again if the condition changes.

You want the loop to do something like:
"if the read value is within the range"
" then enable, and set direction"
" else disable"

Also, using different case but otherwise the same name for variables with different meaning leads to hard-to-reason-about code. Much better to call it "enablePin1" and "enablePin2" for example.
Software / Sharp IR Sensor with arduino
« Last post by Cheetofingers on April 19, 2014, 01:23:54 PM »
Hello, I am having trouble with the IR sensor.

I am trying to make a robot that runs 2 dc motors and 2 IR sensor with arduino.  I am using a breadboard, arduino uno, 2dc motor, 2 sharp infrared sensor (says 2Y0A21 for model?) and an h bridge chip.  The way I want to have it set up is the pin connected to the IR sensor will tell the motors to start or stop based on distance from the IR sensor. A chart i read online says the IR sensor is supposed to return a voltage to the pin based on the distance it reads. (around 3v max at 15cm )
When i first upload my code and have the sensor pointed in a direction, the motors will run based on how far the sensor is from something.  Right now it will only run when something is from 10cm -40cm (2V).  However they only work correctly RIGHT AFTER i upload my code to the arduino.  After that the motors will stay spinning or stay stopped.  Shouldn't the void loop just keep looping and get new values though? Or do I need to write another loop to constantly acquire new voltage values for the pin for when the distance changes? Any ideas?

Here is the code.
const int switchPin = 2;    // switch input
const int motor1Pin = 3;    // H-bridge leg 1 (pin 2, 1A)
const int motor2Pin = 4;    // H-bridge leg 2 (pin 7, 2A)
const int MOTOR1PIN = 5;
const int MOTOR2PIN = 6;
const int enablePin = 9;    // H-bridge enable pin
const int ENABLEPIN = 10;
int sensorpin = 0;
double value;
 void setup()

    // set all the other pins you're using as outputs:
    pinMode(MOTOR1PIN, OUTPUT);
    pinMode(MOTOR2PIN, OUTPUT);
    pinMode(motor1Pin, OUTPUT);
    pinMode(motor2Pin, OUTPUT);
    pinMode(enablePin, OUTPUT);

    // set enablePin high so that motor can turn on:
    digitalWrite(enablePin, HIGH);
    digitalWrite(ENABLEPIN, HIGH);
  void loop()
    value = analogRead(sensorpin);
    // if the sensor pin is greater than 2Volts
    if (value >2) {
      digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low
      digitalWrite(motor2Pin, HIGH);  // set leg 2 of the H-bridge high
      digitalWrite(MOTOR1PIN, LOW);
      digitalWrite(MOTOR2PIN, HIGH);
      digitalWrite(enablePin, LOW);
      digitalWrite(ENABLEPIN, LOW
Mechanics and Construction / robotics hand
« Last post by ansh on April 19, 2014, 05:08:19 AM »
I need some information about robotics hand. I want to know how does finger and thumb make for ROBOTIC hand.
I mean This is hard part for me,

1)which mechanical and electronic components are used to make thumbs and four finger ?
2) If anyone know about any link or thread please share
Electronics / Re: Power Boards
« Last post by jwatte on April 18, 2014, 10:40:13 AM »
If your servos are stalling, then they are not sufficiently specified to do the work they're intended to do. If you cut them off, they will not be able to hold the load.
If that is what you want to do, then you can try:
1) A 1.5A slow-blow fuse.
2) A 1.5A trip-point resettable PTC fuse.
3) A current sensor and a switch/relay of some sort.

The problem with 1) and 2) is that they are not particularly precise, and they are ambient temperature and duty cycle sensitive. Pololu has some nice current sensors for 3) based on the ACS line of Hall effect sensors. Like this one: http://www.pololu.com/product/1185
Read it with a microcontroller, and use a relay or power MOSFET to cut the power.
Misc / Re: Trash robot
« Last post by mickyjune26 on April 18, 2014, 07:47:29 AM »
FYI - I'll be following this blog as part of this project.  Someone is building a full-size TOtT (Take Out the Trash) robot.
Pages: 1 2 3 ... 10

Get Your Ad Here