go_away

Author Topic: $50 Robot's Microcontroller  (Read 716 times)

0 Members and 1 Guest are viewing this topic.

Offline SlotheryTopic starter

  • Jr. Member
  • **
  • Posts: 26
  • Helpful? 0
$50 Robot's Microcontroller
« on: July 28, 2010, 12:17:09 PM »
Alright so I have just assembled my microcontroller and I am having some problems. First of all, the LED does not light up. Then, it seems that when I shine a light directly into one photoresistor and cover the other completely it has no effect on the servos. Finally the servo in slot one will perpetually rotate in one direction while when it is placed in slot two it rotates extremely slow in the other direction.

Please help me with these problems!

Offline Choco_liger

  • Full Member
  • ***
  • Posts: 81
  • Helpful? 3
Re: $50 Robot's Microcontroller
« Reply #1 on: July 28, 2010, 05:47:47 PM »
So, I'm guessing your using the exact same code as the one in the tutorial?

If so, try making these changes
Code: [Select]
int threshold=10;//the larger this number, the more likely your robot will drive straight

Code: [Select]
LED_on();
Code: [Select]
//detects more light on left side of robot
if(sensor_left > sensor_right && (sensor_left - sensor_right) > threshold)
{//go left
servo_left(30);
servo_right(30);
}

//detects more light on right side of robot
else if(sensor_right > sensor_left && (sensor_right - sensor_left) > threshold)
{//go right
servo_left(20);
servo_right(20);
}

//light is about equal on both sides
else
{//go straight
servo_left(20);
servo_right(30);
}

Offline SlotheryTopic starter

  • Jr. Member
  • **
  • Posts: 26
  • Helpful? 0
Re: $50 Robot's Microcontroller
« Reply #2 on: July 29, 2010, 12:24:03 PM »
Thanks for the help!

I edited my code appropriately. My sensors have an effect on my servo but it doesn't seem right. I am using one servo and two sensors. To test I switch the servo between the two rows of pins. In its position closest to the capacitor It will naturally spin quickly clockwise with the ribbon cable pointing up. In this position hovering my hand over the sensor who is closest to the programmer causes the servo to spin slowly counterclockwise. While, putting the servo in slot two it will naturally spin slowly counterclockwise with the ribbon cable pointing up. Then when I hover my hand over the sensor who is farthest away from the programming headers it will quickly spin clockwise.

 


Get Your Ad Here

data_list