Presentation is loading. Please wait.

Presentation is loading. Please wait.

The George Washington University Electrical & Computer Engineering Department Dr. S. Ahmadi Class 3.

Similar presentations


Presentation on theme: "The George Washington University Electrical & Computer Engineering Department Dr. S. Ahmadi Class 3."— Presentation transcript:

1 The George Washington University Electrical & Computer Engineering Department Dr. S. Ahmadi Class 3

2 Agenda Introduce and Discuss Light Sensor Project –Course Layout –Project Description Discussion on Programming Required for Project –Flow Chart of Program Flow –Sample Code

3 Light Sensor Project Course Layout 2m Start Finish

4 Project Description The aim of this project is to design a robot that moves along a given path, from the Start point, towards the Finish line. The thick black line acts as the guide for the robot to follow. As an optional element to the project, after reaching the finish line, the robot should turn around, and go back along the path it came to the starting point. Robot will be judged on smoothness of journey, and robot design. It is the student responsibility to make sure that the Handy Board is fully charged Each group will have one chance to demonstrate their project to the judges. Therefore, fully test your project before demonstration.

5 Diagram of Robot with Light Sensor RO BOT Right LIGHT SensorLeft LIGHT Sensor When RIGHT sensor senses black line turn right (and vice-versa)

6 Discussion on Programming Required for Project

7 Block Diagram For a Right Turn Go Forward Turn Right Yes No Turn Right?

8 Flow Chart to Code for Turning Right Go Forward Turn Right Yes No Turn Right? while (true) { // go forward motor ( 1, 100 ) ; motor ( 3, 100 ) ; // should we turn right? if ( analog(4) > 200 ) { // turn RT, until off black tape ao() ; while (analog(4) > 200) motor (3, 100) ; } Flow Chart C Code Implementation of Flow Chart

9 Block Diagram For a Right Turn or Left Turn Go Forward Turn Right Right turn? Yes No Left turn? Turn Left Yes No

10 Block Diagram for a Complete System Go Forward Turn Right Right turn? Yes No Left turn? Turn Left Yes No Left turn? STOP Yes No

11 Sample Program void main() { int sensor1, sensor3, Flag=1; printf("Press Start button to begin:"); while(start_button()==0); // Waits for start button to be pressed. while(Flag==1) { sensor1=analog(4); // Reads the signal coming from analog port 4. sensor3=analog(6); // Reads the signal coming from analog port 6. motor(1, 10); // GO FORWARD. motor(3, 10);

12 if(sensor1>200) // RIGHT TURN?? { // If Yes then…. if(sensor3>200) // …LEFT TURN?? { // ao(); // Flag=0; // If YES then STOP!!! } else // Right turn = yes BUT Left turn = no, then... { ao(); sleep(2.0); while(analog(4)>200) // Turn RIGHT!! { motor(3,100); }

13 else if(sensor3>200) // LEFT TURN???? { ao(); sleep(2.0); while(analog(6)>200) // TURN LEFT { motor(1,100); }

14 Optional Portion of Project As an optional objective, we wish to make the robot U-turn, and go back along the path to the starting point. This can be carried out in the following way: –After sensing a black surface on BOTH light sensors, the robot stops, and then starts to rotate in either direction. –The robot rotates until the first sensor senses the black line, it CONTINUES rotating, but stops once the second sensor detects the black line. –Once the rotation has been completed, the robot moves along the line in the same way as in the main part of the project until it reaches the start line.


Download ppt "The George Washington University Electrical & Computer Engineering Department Dr. S. Ahmadi Class 3."

Similar presentations


Ads by Google