background image

Copyright © Parallax Inc.

 

 

Infrared Line Follower Kit (#28034) 

v1.0  1/18/2011  Page 7 of 9 

' InfraredLineFollower_Simple.bs2 
' Displays output states of the Infrared Line Follower using the Debug Terminal. 
 
' {$STAMP BS2} 
' {$PBASIC 2.5} 
 
state   VAR    Byte 
 
DO 
  state = INL                                  ' Read input state of pins 0-7 
  DEBUG HOME, "state = %", BIN8 state          ' Display states on Debug Terminal 
LOOP 

 

Propeller P8X32A Example Code  

The program below will test the Infrared Line Follower sensors before they’re used in a line-following 

application. Follow the instructions below to test that all 8 sensors are working correctly. 
 

 

Affix a 3/4" piece of electrical tape on a white piece of paper. 

 

Enter & run InfraredLineFollower_Simple.spin. 

 

Place S0 over the electrical tape, and the other sensors over the white paper. 

 

The Parallax Serial Terminal should read %00000001 and the S0 LED should be off. 

 

Repeat this process until all eight sensors are tested. 

 

If your sensor doesn’t display a logical 1 when over a black line and logical 0 when over a white line, 

check your connections and/or try adjusting the frequency in the Calibration section on page 8. 

 

'' InfraredLineFollower_Simple.spin 
'' Displays output states of the Infrared Line Follower using the Parallax Serial Terminal. 
 

  _clkmode = xtal1 + pll16x 
  _xinfreq = 5_000_000 
 

VAR 
 
  byte  state 

 
OBJ 
 

  pst : "Parallax Serial Terminal" 
   
PUB Main 

   
  outa[0..7]~                            ' Sets pins 0-7 as input                                           
  pst.start(115_200)                     ' Initialize Parallax Serial Terminal 

  waitcnt(c cnt) 
   
  repeat 

    state := ina[7..0]                   ' Read the states of pins 0-7 
    pst.home                             ' Set cursor to upper left corner 
    pst.bin(state, 8)                    ' Display states in PST 

    waitcnt(clkfreq/200 + cnt)     

Summary of Contents for 28034

Page 1: ...nly needs to read the state of each IR receiver to detect white or black surfaces An Enable pin is also included which when pulled low puts the Infrared Line Follower into low power mode Features Compatible with both the Boe Bot and Stingray robots from Parallax Onboard 3 V regulator for easy use with Propeller powered robots Easily adjust 38 43 kHz IR frequency using an onboard potentiometer See ...

Page 2: ...ack surface no light is reflected to the IR receiver and its output is high The voltage regulator included on the PCB limits the power to the Infrared Line Follower s circuitry to 3 V This means that a 5 V supply can safely be used with microcontrollers operating at 3 3 V Red LEDs located on the top of the board are wired to the output of each IR receiver and the anode of each LED is connected to ...

Page 3: ... you will need a strip of black electrical tape on white paper Boe Bot Assembly Instructions To mount the Infrared Line Follower on your Boe Bot robot you will need the following materials 2 7 8 4 40 pan head screws 2 1 4 4 40 pan head screws 2 1 round standoffs 2 1 2 round spacers Step 1 Insert the 7 8 screws through the top of the Boe Bot chassis through the left and right slots at the front Ste...

Page 4: ...o the screws The Infrared Line Follower should be facing downward with the headers pointing toward the tail wheel Stingray Assembly Instructions To mount the Infrared Line Follower on your Stingray you will need the following materials 2 7 8 4 40 pan head screws 2 1 2 round spacers 2 4 40 x 3 8 nuts Step 1 Remove the front Stingray plate and insert the 7 8 screws through the top of the chassis thr...

Page 5: ...ng downward with the headers pointing toward the tail wheel Pin Definitions Pin Name Type Function 1 GND G Ground 0V 2 Vdd P Supply Voltage 3 EN I Enable pin pull low for low power mode 4 OUT0 O Output state of IR receiver 0 5 OUT1 O Output state of IR receiver 1 6 OUT2 O Output state of IR receiver 2 7 OUT3 O Output state of IR receiver 3 8 OUT4 O Output state of IR receiver 4 9 OUT5 O Output sta...

Page 6: ...age Go to www parallax com and search 28230 Figure 1 Infrared Line Follower Quick Start Circuit BASIC Stamp 2 Example Code The program InfraredLineFollower_Simple bs2 will test the Infrared Line Follower sensors before they re used in a line following application Follow the instructions below to test that all 8 sensors are working correctly Affix a 3 4 piece of electrical tape on a white piece of ...

Page 7: ... over the electrical tape and the other sensors over the white paper The Parallax Serial Terminal should read 00000001 and the S0 LED should be off Repeat this process until all eight sensors are tested If your sensor doesn t display a logical 1 when over a black line and logical 0 when over a white line check your connections and or try adjusting the frequency in the Calibration section on page 8...

Page 8: ...ow can be used for simple Boe Bot line following applications and is compatible with the circuit shown in Figure 1 Keep in mind that this is not the most robust line following code which can and should be expanded to better fit your needs InfraredLineFollower_BoeBot bs2 Simple line following Boe Bot code using the Infrared Line Follower STAMP BS2 PBASIC 2 5 DO SELECT INL Select line follower state...

Page 9: ...ected to P25 MotorB 26 Motor B connected to P26 VAR byte DutyCycleA DutyCycleB state OBJ PWM PWM_32_V2 spin PUB Main PWM Start Start PWM object dira 7 0 Set pins 7 0 as input repeat state ina 7 0 Set input states to variable state case state 00000011 00000001 00000010 Pivot left DutyCycleA 65 DutyCycleB 0 00000111 00000110 00000100 Slight left DutyCycleA 60 DutyCycleB 0 00001110 00001100 Adjust le...

Page 10: ...Mouser Electronics Authorized Distributor Click to View Pricing Inventory Delivery Lifecycle Information Parallax 28034 ...

Reviews: