PDA

View Full Version : Photoresistor help



Shy
08-18-2008, 06:05 PM
Hi,

I have boe-bot robot. on it ping and infrared head lights are also working. now i want when my robot go into low intensity light area it shutdown, means stop working.

·

dandreae
08-18-2008, 09:10 PM
In Chapter 6 of the "Robotics with the Boe-Bot" it explains how the photoresistors work.· Based on the value of the photoresistor you can create a subroutine that puts the BASIC Stamp in "Sleep" mode.· The Sleep mode puts the BASIC Stamp into a low power mode for up to 18 hours.· You can find more information regarding the "SLEEP" command in the "BASIC Stamp Syntax and Reference Manual.

Dave

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae

Parallax Tech Support·

Shy
08-18-2008, 11:04 PM
Thank you for reply. i want the robot to remain in sleep mode·during the period
, thephotoresistors remain in shadow. but when light falls on·robot it should wake up·

Tracy Allen
08-19-2008, 12:22 AM
The SLEEP command will be in a loop in your program. It goes into low power mode for say 1 minute, wakes up briefly to check the light level, and either go back to sleep for another minute or activate.

DO
SLEEP 60
GOSUB seethelight
LOOP UNTIL light > threshold

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Shy
08-19-2008, 07:24 AM
Thanks again, Please tell me

DO
SLEEP 60
GOSUB seethelight
LOOP UNTIL light > threshold

is it the complete code, i am little confused about subroutine·{·GOSUB seethelight} , please explaine

Franklin
08-19-2008, 08:23 AM
Shy said...
is it the complete code, i am little confused about subroutine·{·GOSUB seethelight} , please explaine

This is not the whole code, just the part that sleeps while dark the GOSUB would go to code you write that does the things when it is light.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

Shy
08-19-2008, 07:05 PM
i am attaching here code, please insert in photoresistor command, you have told me,·in it

Tracy Allen
08-20-2008, 12:51 AM
Do you have a photoresistor? What is its electrical resistance at the light level that would be the border between lignt and dark? The code you have is basically the Ping demo written by Andy Lindsay at Parallax, and it does not yet have any provision for the light sensor.

You can connect the photoresistor in series with a fixed resistor from Vdd to Vss, and the junction to a Stamp pin, so that PBASIC will read 1 on that pin in the dark and 0 in the light. You have to discover the correct value of fixed resistor or provide more information about your photoresistor.




fixedR photoR
+5 ---/\/\---o---/\/\---- Vss
|
p0



Then at the end of the main loop, add the lines marked with "<-------":



Main:
DO

FREQOUT 8, 1, 38500 ' Emit 38.5 kHz IR To Left
irDetectLeft = IN9 ' Store IR Detection Values

FREQOUT 2, 1, 38500 ' Emit 38.5 kHz IR To Right
irDetectRight = IN0 ' Store IR Detection Values

IF (irDetectLeft = 0) AND (irDetectRight = 0) THEN
GOSUB Ping_Around ' Object Detected via IR Forward
ELSEIF (irDetectLeft = 0) THEN
GOSUB Ping_Around ' Object Detected via IR Left
ELSEIF (irDetectRight = 0) THEN
GOSUB Ping_Around ' Object Detected via IR Right
ENDIF

counter = counter + 1 ' Increment Passive Counter

IF counter > 10 THEN ' Wait For 10 Servo Pulses
GOSUB Ping_Out ' Activate PING)))
ENDIF

IF (distance > 30) THEN ' Is Object Farther Than 30 cm?
GOSUB Forward_Pulse ' If Yes Go Forward
ELSE
GOSUB Ping_Around ' Otherwise Scan For Clear Path
ENDIF

dark PIN 0 ' <------- whatever pin you want to use for the light sensor
DO WHILE dark ' <------- this will only execute when it is dark, pin level high
SLEEP 60 ' <------- sleep in increments of 60 seconds
LOOP ' <------- recheck for light once a minute, and back to work when light

LOOP

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

Shy
08-20-2008, 10:01 PM
thanks Allen it works.