F I S H B O W L

p r o j e c t 1 :: w e e k 3

P R O G R E S S

      1  Group decided to keep orginial idea and try to experiment with envirnoment one apparatus is built.

      2  I purchased a new gold fish and bowl to use in lab project. Other group members bought materials to construct table.

      3  Begin constructed preliminary circuit board.  Group members began embedding sensors in table.
                        
      
      4  Wrote initial code for sensor :
       
'****************************************************************
'*  Name    : Fish Bowl Project 1.0                             *
'*  Author  :  Alysse                                           *
'*  Date    : 10/6/2004                                         *
'*  Version : 1.0                                               *
'*  Notes   :   1.Includes serial output to monitor data from
'*              optical sensor.
'*              2.  When output from data from optical sensor
'*               falls below a certain range
'*              servo makes a clear swipe back and forth  -
'*              swipe indicates striking chime back and forth
'*              (servo pauses after action)
'*              3. Strength of shadow influences the speed of the
'*                 swipe..
'*                      dark shadow = fast strike
'*                      light shadow = slow strike
                                                        *
'*                                                          *
'****************************************************************
' Code for Servo Motor
DEFINE OSC 4
DEFINE  ADC_BITS        10   ' Set number of bits in result
DEFINE  ADC_CLOCK       3       ' Set clock source (3=rc)
DEFINE  ADC_SAMPLEUS    50      ' Set sampling time in uS

TRISA  = %11111111              ' Set PORTA to all input
ADCON1 = %10000010              ' Set PORTA analog and right justify result
PORTD  = %00000000              ' Set PORTC to all output
PORTC  = %00000000              ' Set PORTD to all output

ADCvar     VAR WORD
ylLED      VAR PORTD.1
txPin      VAR PORTC.6
servo_1    VAR PORTC.3
pulseWidth VAR WORD
pulseRange VAR WORD
i VAR BYTE

shadowLevel CON 90 ' based on obsevations with chip

' set up constants with the minimum and maximum pulsewidths
minPulse CON 50
maxPulse CON 150

refreshPeriod CON 20
pulseWidth = minPulse 'initial pulse width
pulseRange = maxPulse - minPulse

PAUSE 500

GOSUB blink

main:
   ADCIN 0, adcVAR
   ' check value on screen with serial out
   serout2 txPin, 16468, ["light sensor = ", DEC ADCvar, 13, 10]

   if ADCvar < shadowLevel THEN
       PULSEWIDTH = ADCvar + minPulse;
       ' Note : darker shadows = smalle sensor value.  Therefore
       ' light angles have longer slower arc
       SEROUT2 txPin, 16468, ["pulseWidth = ", DEC pulseWidth, 13, 10]
       for i= minPULSE to pulseWidth  step  1
           LOW PORTC.3
               PULSOUT PORTC.3, i
               PAUSE 5

       NEXT i
       PAUSE pulseWidth
       for i =maxPulse to pulseWidth STEP -1
           LOW PORTC.3
               PULSOUT PORTC.3, i
               pause 5
       NEXT i
       ENDIF

GoTo main

blink:
HIGH ylLED
PAUSE 300
LOW ylLED
PAUSE 300
HIGH ylLED
PAUSE 300
LOW ylLED
PAUSE 300
HIGH ylLED
PAUSE 300
LOW ylLED
PAUSE 300
HIGH ylLEd
return