Things used in this project

Hardware components:
Msp exp430f5529lp 5529 lp angle%5b1%5d
TI LaunchPad MSP-EXP430F5529LP MSP430 LaunchPad
×1
Adafruit industries ada161 image 75px
Photo resistor
×2
Sharp microelectronics gp2y0a41sk0f image
Proximity Sensor
×1
Texas instruments l293dne image
Texas Instruments Dual H-Bridge motor drivers L293D
×1
DC motor (generic)
×2
09590 01
LED (generic)
Optional
×2
Mfr 25frf52 10k sml
Resistor 10k ohm
×2
12002 04
Breadboard (generic)
×1
11026 02
Jumper wires (generic)
×1
Adafruit industries ada830 image 75px
4xAA battery holder
×1
61vhxtmzbyl
AA Batteries
×1
Software apps and online services:
Ccscube256
Texas Instruments Code Composer Studio
Energiabadgelogo2
TI LaunchPad Energia
Alternative
Hand tools and fabrication machines:
09507 01
Soldering iron (generic)

Code

Main ProgramC/C++
Use Code Composer Studio, Code Composer Studio Cloud, or Energia
void setup() {
  // put your setup code here, to run once:
  analogReadResolution(12);
  Serial.begin(9600);

  pinMode(29, OUTPUT); //MOTOR 1
  pinMode(30, OUTPUT);

  pinMode(32, OUTPUT); //MOTOR 2
  pinMode(31, OUTPUT); 
}

void loop() {
  // put your main code here, to run repeatedly: 
  int photo1 = analogRead(23);//photoresistor1 is connected to analog pin 23
  int photo2 = analogRead(24);//photoresistor2 is connected to analog pin 24
  int ir = analogRead(25);//IR sensor is connected to analog pin 25
  Serial.print(photo1);
  Serial.print("      ");
  Serial.print(photo2);
  Serial.print("     ");
  Serial.println(ir);
  
  //***THRESHOLD VALUES MAY NOT BE THE SAME FOR YOU***
  //Use the displayed values on the serial port to find out
  //what threshold values should be used for you

  //The following case occurs when both photoresistors(LDRs)
  //detect white
  if (photo1 > 2900 && photo2 > 2200 && ir < 2000)
  {
   digitalWrite(29, HIGH);//HIGH for forward
   digitalWrite(30, LOW); //LEFT MOTOR GOES FORWARD

   digitalWrite(32, HIGH);//HIGH for forward
   digitalWrite(31, LOW); //RIGHT MOTOR GOES FORWARD
    
  }
  
  /*The following case occurs if the right LDR detects black 
   * and the left LDR detects white
   */
   else if (photo1 < 2900 && photo2 > 2200 && ir < 2000)
  {

   digitalWrite(29, HIGH);
   digitalWrite(30, LOW); //LEFT MOTOR GOES FORWARD

   digitalWrite(32, LOW);
   digitalWrite(31, HIGH); //RIGHT MOTOR GOES BACKWARDS
  }
  
   /*The following case occurs if the left LDR detects black 
    * and the right LDR detects white
    */
    else if (photo1 > 2900 && photo2 < 2200 && ir < 2000)
  {

   digitalWrite(29, LOW);
   digitalWrite(30, HIGH); //LEFT MOTOR GOES BACKWARDS

   digitalWrite(32, HIGH);
   digitalWrite(31, LOW); //RIGHT MOTOR GOES FORWARD
  }

  /*The following case occurs if the robot reaches a 90 degree
   *turn. In this case, it will turn left because the specific
   *setup of lines I had for my assignment had 90 degree turns
   *go left and not right. If you want to have a variation of
   *turning left and right for 90 dgree turns, an additional
   *photoresistor(LDR) is needed between the two, and if the 
   *middle LDR and left LDR detects black, it should turn left.
   *Similarly, if the middle LDR and right LDR detects black, it
   *should turn right.
   */
  else if (photo1 < 2900 && photo2 < 2200 && ir < 2000)
  {

   digitalWrite(29, LOW);
   digitalWrite(30, HIGH); //LEFT MOTOR GOES BACKWARDS

   digitalWrite(32, HIGH);
   digitalWrite(31, LOW); //RIGHT MOTOR GOES FORWARD
  }
 
   //The following case occurs if the an object is close
  else if (ir > 2000)
  {
   digitalWrite(29, LOW);
   digitalWrite(30, LOW); //LEFT MOTOR STOPS

   digitalWrite(32, LOW);
   digitalWrite(31, LOW); //RIGHT MOTOR STOPS
  }
  delay(50);
}

Credits

Mjoyqfasn0zslpeg4vrc
Ali Soomar

Student at the University of Texas at Austin

Contact
Okefyxxiqf9txr4wd3hw
Rohan Balaji

Student at The University of Texas at Austin

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Wi-Fi IoT Workshop for TI LaunchPad+Educational BoosterPack
Easy
  • 1,350
  • 121

Full instructions

Get started with some IoT projects. Learn how to use Wi-Fi wireless communication with the TI LaunchPad.

ASEE 2017: TI LaunchPad 4 Student Owned Freshman Experience
Easy
  • 133
  • 1

Protip

Learn how to use low cost student owned hardware for hands on intro courses.

Control Your Bot From Anywhere
Easy
  • 18
  • 0

Full instructions

IoT with your robot at one place and your phone another, both connected via internet.

MSP432 Fun with IoT Workshop 2016
Easy
  • 3,288
  • 68

Full instructions

Explore the Educational BoosterPack paired with the MSP432 LaunchPad and then take that to the cloud with the CC3100 Wi-Fi BoosterPack!

MIT IAP 2016 Lab
Easy
  • 1,962
  • 46

A collection of the 6 labs for the MIT IAP Texas Instruments LaunchPad Workshop

Texas Instruments MSP-EXP432 - MultiTasking
Easy
  • 583
  • 18

Protip

MultiTasking ultrasonic and color sensor with Texas Instruments MSP-EXP432 and Energia.

Add projectSign up / Login