0% found this document useful (0 votes)
15 views5 pages

03 Laboratory Exercise 1

Uploaded by

cruzpatrick54
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

03 Laboratory Exercise 1

Uploaded by

cruzpatrick54
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

IT2315

Rocabo jonray
Laboratory Exercise
IR Sensors: Line Follower
Objective:

At the end of the exercise, the students should be able to:

 Demonstrate how to control robots using IR sensors.

Requirements:

 PBOT Jr. Standard kit


 Arduino IDE

Sensor Pins
The 3-channel Line sensor P6 has an analog comparator to change analog voltage appearing as
its input into a single-bit digital logic signal.
The reference voltage is fed to the positive input of the comparator. If the analog input fed
through the input exceeds the refer voltage, the comparator output switches to logic LOW, or else,
it assumes a logic HIGH state.
The sensitivity of the three comparators can be independently set by adjusting their reference
voltage through their corresponding adjustable trimmers.
A 3-channel analog comparator is a typical analog interface circuit. It can also be used with other
sensors with 0~5VDC output range functioning as a single-bit ADC.
Here are the following line sensor pin assignments:
 Pin 5 = Left Line Sensor
 Pin 6 = Center Line Sensor
 Pin 7 = Right Line Sensor

The void setup will be used to specify the pinMode of the line sensors which are all INPUT. The
configuration of the line sensors in the void loop() or a function will be based on the set if-else
condition such as:
if(digitalRead(LN) == 0 && digitalRead(RN) == 0){ //indicates that all IR detected a
black surface, thus
forward();
}

03 Laboratory Exercise 1 *Property of STI


Page 1 of 5
IT2315

Procedure (60 points)


1. Code the PBOT Jr. that uses its IR sensors to trace the following line tracks.
Line A

Line B

2. Call on the instructor to demonstrate the exercise before submitting a PDF copy of the
code on eLMS. Ensure that each member submits.

#defin
e MS
12
//
Middle
Sensor
#define LS 13 // Left sensor
#define RS 11 // Right sensor

#define LM1 2 // left motor


#define LM2 3 // left motor
#define RM1 4 // right motor
#define RM2 5 // right motor

void setup()
{
Serial.begin(9600);
pinMode(MS, INPUT);
pinMode(LS, INPUT);
pinMode(RS, INPUT);
pinMode(LM1, OUTPUT);
pinMode(LM2, OUTPUT);
pinMode(RM1, OUTPUT);
pinMode(RM2, OUTPUT);
}

03 Laboratory Exercise 1 *Property of STI


Page 2 of 5
IT2315

void loop()
{

if(digitalRead(MS)) // Middle Sensor On Line


{
if(!digitalRead(LS) && !digitalRead(RS)) //LS and RS not
on line
{
Serial.println("move forward");
digitalWrite(LM1, LOW);
digitalWrite(LM2, HIGH);
digitalWrite(RM1, LOW);
digitalWrite(RM2, HIGH);
}
else if(digitalRead(LS) && !digitalRead(RS)) //Sharp Left
{
Serial.println("Sharp Left");
digitalWrite(LM1, LOW);
digitalWrite(LM2, HIGH);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
}
else if(!digitalRead(LS) && digitalRead(RS)) //Sharp Right
{
Serial.println("Sharp Right");
digitalWrite(LM1, HIGH);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, HIGH);
}
else if(digitalRead(LS) && digitalRead(RS))
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);
Serial.println("Stop");
}
}
else
{
if(digitalRead(LS) && !digitalRead(RS)) // Turn left

03 Laboratory Exercise 1 *Property of STI


Page 3 of 5
IT2315

{
digitalWrite(LM1, LOW);
digitalWrite(LM2, HIGH);
digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);
Serial.println("Left");
}
else if(!digitalRead(LS) && digitalRead(RS)) // turn
right
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, HIGH);
Serial.println("Right");
}
else if(!digitalRead(LS) && !digitalRead(RS)) // turn
right
{
digitalWrite(LM1, LOW);
digitalWrite(LM2, LOW);
digitalWrite(RM1, LOW);
digitalWrite(RM2, LOW);
}
}
delay(5);
}
3.

03 Laboratory Exercise 1 *Property of STI


Page 4 of 5
IT2315

GRADING RUBRIC
Excellent Good Fair Poor
Criteria Points
4 3 2 1
The students did The student The student The student
Completeness
all missed a few of missed most of the missed all of the /20
(x5) the requirements. the requirements. requirements. requirements.
The code is The code is The code is The code is
Coding complete and complete but properly incomplete and
/20
(x5) properly improperly structured but improperly
structured. structured. incomplete. structured.
The robot traced The robot traced The robot The robot
Consistency all line tracks with all line tracks traced one (1) traced one (1)
/20
(x5) excellent with good line track with line track with
consistency. consistency. excellent good
consistency consistency
Total Score /60

03 Laboratory Exercise 1 *Property of STI


Page 5 of 5

You might also like