Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 IR Sensor and Emitter
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
sjb




PostPosted: Sat Jan 14, 2006 11:09 am   Post subject: IR Sensor and Emitter

Hi, I'm making a security system for a physics ISU, and i used the book Networks, Interfaces, and integrated circuits and in it, it has the program intruder alert (10.6.8) anyways, ive hooked the whole thing up...and it does not work, ive been troubleshooting for 2 weeks now and i cant find the problem, and its due on thursday, unfortunately the course thats associated with the book is not done at my school so i cant ask a teacher, so I am hoping someone here will be able to help me..

the program is at the bottom if you want to look at it but whats supposed to happen is that D0 on the parallel port is supposed be activated when you click arm with parallelput (1) and the reciever recieves the signal from the emitter and sends back to the computer that its recieving a signal, so the computer states that there are intruders, however if this signal is broken it sets off a buzzer.

My problem is, the infrared emitter and detector arent doing anything, the parallelget command from what ive seen, always stays constant, and nothing is changing it....
i did a small program on the side to see what the parallelget was coming to and it was 120.... so im guessing my numbers are different than the ones they assumed but i dont know what to do with these numbers or how to get the IR sensor and emitter to work


code:
% The "IntruderAlert" program

%D0 (pin2) sends power to the emitter.
%D1 (pin3) activates the IR been when the Arm boxis clicked
%I0 (pin10) connects to the IR receiver. I0 is 1 id the emitter is given
%power and the IR receiver is receiving the bea.

% These are the locations of the boxes. (x1,y1) is the lower left corner
% of the box and (x2,y2) is the upper-right corner.

const armBoxX1 := 20
const armBoxY1 := 270
const armBoxX2 := 80
const armBoxY2 := 310
const disarmBoxX1 := 20
const disarmBoxY1 := 210
const disarmBoxX2 := 80
const disarmBoxY2 := 250
const quitBoxX1 := 20
const quitBoxY1 := 150
const quitBoxX2 := 80
const quitBoxY2 := 190

% For this computer, 63 means that light is shining on the reciever.
% The receiver is receiving light from the emitter.
% For this computer, 127 means that light is not shinning on the receiver.
% The beam is broken.

setscreen ("graphics")

% x,y is the mosition of the mouse.
% button is the variable determining if the mouse button is pressed.
var x, y, button : int
var value : int
% armed indicates whether or not the alarm is currently armed
var armed : boolean := false

% Draws the titles.
colour (red)
locatexy (230, 380)
put "Home Security System"
locatexy (0, 320)
colour (black)
put "Control Panel"


% Draws the "Quit" box.
drawbox (quitBoxX1, quitBoxY1, quitBoxX2, quitBoxY2, black)
locatexy (quitBoxX1 + 20, quitBoxY1 + 20)
colour (black)
put "Quit" ..

% Draws the "Disarm" box.
drawbox (disarmBoxX1, disarmBoxY1, disarmBoxX2, disarmBoxY2, green)
locatexy (disarmBoxX1 + 10, disarmBoxY1 + 20)
colour (green)
put "Disarm" ..

% Draws the "Arm" box.
drawbox (armBoxX1, armBoxY1, armBoxX2, armBoxY2, red)
locatexy (armBoxX1 + 20, armBoxY1 + 20)
colour (red)
put "Arm" ..

loop
    % Locates the current mouse position
    mousewhere (x, y, button)
    if quitBoxX1 <= x and x <= quitBoxX2 and
            quitBoxY1 <= y and y <= quitBoxY2 and button = 1 then
        % If the Quit box is clicked, sets all pins on parallel port to 0.
        % The system is now shut down.
        locatexy (200, 200)
        colour (black)
        put "The Security System is Shut Down"
        parallelput (0)
        locatexy (200, 180)
        put ""
        exit
    elsif disarmBoxX1 <= x and x <= disarmBoxX2 and
            disarmBoxY1 <= y and y <= disarmBoxY2 and button = 1 then
        % If the Disarm box is clicked, sets all pins on parallel port to 0.
        % to shut off infrared emitter.
        %The program continues to wait for another command.
        locatexy (200, 200)
        colour (green)
        put "The Security System is Disarmed"
        parallelput (0)
        armed := false
        locatexy (200, 180)
        put ""
    elsif armBoxX1 <= x and x <= armBoxX2 and
            armBoxY1 <= y and y <= armBoxY2 and button = 1 then
        % If the Arm box is clicked, sets D0 pin to 1 to the
        % activating the emitter.
        locatexy (200, 200)
        colour (red)
        put "The Security System is Armed"
        parallelput (1)
        armed := true
    end if

    % If the system is armed, tests the results of the IR receiver by
    % checking the input pin I0 on the parallel port
    if armed then
        value := parallelget

        if (value div 64) mod 2 = 1 then
            % If I0 is 1, the Ir receiver is getting light.
            locatexy (200, 180)
            put "Situation normal. No intruders detected"
        else
            % if I0 is 0, the beam has been interrupted
            locatexy (200, 180)
            put "INTRUDER ALERT"
            %Set d0 and d1. d) continues to providee power and D1
            %starts the buzzer.
            parallelput (3)
        end if
    end if
end loop


Any help or insight is appreciated, even if it has to do with the properties of the IR detector and emittor
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: