Author Topic: photoresistor(50$ robot)  (Read 4239 times)

0 Members and 1 Guest are viewing this topic.

Offline mohamedTopic starter

  • Full Member
  • ***
  • Posts: 88
  • Helpful? 0
photoresistor(50$ robot)
« on: April 11, 2008, 05:33:56 PM »
could any one tell me how i know that the photoresistors of the robot are working fine
as i connected them to the circuit(red to the middle, blue near the AT mega8 and the black far from the microcontroller)as when i face the robot to the wall the servos didn't change there direction to avoid the wall so what should i do?!!!

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: photoresistor(50$ robot)
« Reply #1 on: April 11, 2008, 11:51:51 PM »
Photoresisters have nothing to do with a wall.

They look for light on the floor. If you have light coming in through a window onto the floor put it in there and it will stay in that light box on the floor.

Offline mohamedTopic starter

  • Full Member
  • ***
  • Posts: 88
  • Helpful? 0
Re: photoresistor(50$ robot)
« Reply #2 on: April 12, 2008, 02:13:47 AM »
now I'm confused  ??? is it supposed that this robot is going to avoid obstacles?
also i want to know how to connect my photoresistor to the board (power wire to the middle, ground far from he mcu and signal near the mcu) correct me if I'm wrong

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
    • Ro-Bot-X Designs
Re: photoresistor(50$ robot)
« Reply #3 on: April 12, 2008, 02:16:37 AM »
Photoresistors are passive sensors, that means they don't need to be powered. So you need to connect it to the ground and signal line.
Check out the uBotino robot controller!

Offline mohamedTopic starter

  • Full Member
  • ***
  • Posts: 88
  • Helpful? 0
Re: photoresistor(50$ robot)
« Reply #4 on: April 12, 2008, 02:35:26 AM »
thanks ro-bot-x but i want to know after i finish building the robot is it going to avoid obstacles or not?

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: photoresistor(50$ robot)
« Reply #5 on: April 12, 2008, 11:57:15 AM »
It needs voltage to pass through it though.

The photosensors are used to do light chasing, light avoiding, or line following or line avoiding.

Offline cooldog

  • Supreme Robot
  • *****
  • Posts: 751
  • Helpful? 4
  • be nice to nerds, one day they will be your boss
Re: photoresistor(50$ robot)
« Reply #6 on: April 12, 2008, 02:09:38 PM »
now I'm confused  ??? is it supposed that this robot is going to avoid obstacles?

no iot avoides the shadows the obstacles make. if you want a obstacle avoider you have to do the sharp IR upgrade and use this code

Code: [Select]
/****************************************************************************
*
*   Copyright (c) 2007 www.societyofrobots.com
*   (please link back if you use this code!)
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License version 2 as
*   published by the Free Software Foundation.
*
*   Alternatively, this software may be distributed under the terms of BSD
*   license.
*
* $50 Robot with Sharp IR using Stampy Technology v1, May 19th, 2007
* Simple case-based method for a robot to do edge detection.
*
*
****************************************************************************/

//SoR Include
#include "SoR_Utils.h" //includes all the technical stuff

//global variables
int sharp_IR_reading=0;

int scan_thresh=0;//threshold value of scanning sensor

int scan_angle=30;//position of scanner, in units of servo command
int max_scan_angle=56;//maximum position scanner can rotate to (57)


//this function causes scanning servo to center on edge of object
void scan(void)
{
//lower (-) goes right
//higher (+) goes left
//30 far right, 50 straight, 56 far left (until it jams)



sharp_IR_reading=a2dConvert8bit(3);

if (sharp_IR_reading > scan_thresh)//object detected
{
if (scan_angle>41) //overflow protection
scan_angle-=2;//scan right
}
else //object not detected
{
if (scan_angle<=max_scan_angle) //maximum servo angle
scan_angle+=2; //scan left
else //if scanned all the way, this forces it to start over
scan_angle=30;
}

//servo scan code
servo_scan(scan_angle);
}


//automatically calculates threshold value before run
void autocalibrate(void)
{
scan_thresh=a2dConvert8bit(3);//sensor reading
}

int main(void)
{
//LED_on();

initialize();

delay_cycles(42000);//two second wait delay

/*********ADD YOUR CODE BELOW THIS LINE **********/

//find thresholds
autocalibrate();

//LED_off();


while(1)
{
scan();

if (sharp_IR_reading > scan_thresh)

robot_turn_right();


//object is centered
else
robot_go_straight();

delay_cycles(400);//a small delay to prevent crazy oscillations
}
/*********ADD YOUR CODE ABOVE THIS LINE **********/

return 0;
}


/*********************COMMAND LIST*************************

delay_cycles(cycles);
Delays - you can make your robot wait for a certain amount of time with this function.
Put the number of computational cycles to delay in the ().
23 cycles is about .992 milliseconds
to calculate: 23/.992*(time in milliseconds to delay) = cycles
Check servo datasheet where it says: 'Direction: Clockwise/Pulse Traveling 1500 to 1900usec'

servo_left(speed); and servo_right(speed);
Commands your servos to rotate at a certain speed.
Vary speed (which represents a delay in cycles) from 20 to 50.
Left is for port D0 and right is for port D1.

robot_turn_left(); and robot_turn_right(); and robot_go_straight();
Dont want to deal with speed?
Just call this function and it will 'just work.'

LED_on(); and LED_off();
Turns on and off your LED. The LED is on port D4.
By bringing port D4 low, you are turning on the LED.


variable=a2dConvert8bit(pin);
Reads analog pin. For example, set 'pin' to 5 to read PC5.
'variable' will store the value.

***********************************************************/
robot will rule the world and i will be building them
-admin

favorite web sites
http://www.societyofrobots.com/
http://www.instructables.com/

 

SMF spam blocked by CleanTalk