Components and supplies
Standard LCD - 16x2 White on Blue
12VDC & 1 Amp Adapter
Jumper wires (generic)
Arduino UNO
Infra Red Obstacle Sensor
Apps and platforms
Arduino IDE
Project description
Code
Code
c_cpp
1#include <LiquidCrystal.h> 2const int FROS = A1; 3const int FLOS = A2; 4const int RROS = A3; 5const int RLOS = A4; 6int FR = 0; 7int FL = 0; 8int RR = 0; 9int RL = 0; 10LiquidCrystal lcd(8, 9, 4, 5, 6, 7); 11void setup() 12{ 13 lcd.begin(16, 2); 14 pinMode(FROS, INPUT); 15 pinMode(FLOS, INPUT); 16 pinMode(RROS, INPUT); 17 pinMode(RLOS, INPUT); 18 Serial.begin(9600); 19} 20void loop() 21{ 22 FR = analogRead(FROS); 23 Serial.println(FR); 24 FL = analogRead(FLOS); 25 RR = analogRead(RROS); 26 RL = analogRead(RLOS); 27 lcd.setCursor(1, 0); 28 lcd.print("FR FL RR RL"); 29 if (FR <= 500 && FL <= 500 && RR <= 500 && RL <= 500) 30 { 31 lcd.setCursor(1, 1); 32 lcd.print("No Obstacle "); 33 } 34 else if (FR > 500 && FL <= 500 && RR <= 500 && RL <= 500) 35 { 36 lcd.setCursor(1, 1); 37 lcd.print("XX "); 38 } 39 else if (FR <= 500 && FL <= 500 && RR <= 500 && RL > 500) 40 { 41 lcd.setCursor(1, 1); 42 lcd.print(" XX"); 43 } 44 else if (FR <= 500 && FL <= 500 && RR > 500 && RL <= 500) 45 { 46 lcd.setCursor(1, 1); 47 lcd.print(" XX "); 48 } 49 else if (FR <= 500 && FL <= 500 && RR > 500 && RL > 500) 50 { 51 lcd.setCursor(1, 1); 52 lcd.print(" XX XX"); 53 } 54 else if (FR <= 500 && FL > 500 && RR <= 500 && RL <= 500) 55 { 56 lcd.setCursor(1, 1); 57 lcd.print(" XX "); 58 } 59 else if (FR <= 500 && FL > 500 && RR <= 500 && RL > 500) 60 { 61 lcd.setCursor(1, 1); 62 lcd.print(" XX XX"); 63 } 64 else if (FR <= 500 && FL > 500 && RR > 500 && RL <= 500) 65 { 66 lcd.setCursor(1, 1); 67 lcd.print(" XX XX "); 68 } 69 else if (FR <= 500 && FL > 500 && RR > 500 && RL > 500) 70 { 71 lcd.setCursor(1, 1); 72 lcd.print(" XX XX XX"); 73 } 74 else if (FR > 500 && FL <= 500 && RR <= 500 && RL <= 500) 75 { 76 lcd.setCursor(1, 1); 77 lcd.print("XX "); 78 } 79 else if (FR > 500 && FL <= 500 && RR <= 500 && RL > 500) 80 { 81 lcd.setCursor(1, 1); 82 lcd.print("XX XX"); 83 } 84 else if (FR > 500 && FL <= 500 && RR > 500 && RL <= 500) 85 { 86 lcd.setCursor(1, 1); 87 lcd.print("XX XX "); 88 } 89 else if (FR > 500 && FL <= 500 && RR > 500 && RL > 500) 90 { 91 lcd.setCursor(1, 1); 92 lcd.print("XX XX XX"); 93 } 94 else if (FR > 500 && FL > 500 && RR <= 500 && RL <= 500) 95 { 96 lcd.setCursor(1, 1); 97 lcd.print("XX XX "); 98 } 99 else if (FR > 500 && FL > 500 && RR <= 500 && RL > 500) 100 { 101 lcd.setCursor(1, 1); 102 lcd.print("XX XX XX"); 103 } 104 else if (FR > 500 && FL > 500 && RR > 500 && RL <= 500) 105 { 106 lcd.setCursor(1, 1); 107 lcd.print("XX XX XX "); 108 } 109 else 110 { 111 lcd.setCursor(1, 1); 112 lcd.print("Call Help ...... "); 113 } 114} 115
Code
c_cpp
1#include <LiquidCrystal.h> 2const int FROS = A1; 3const int FLOS = 4 A2; 5const int RROS = A3; 6const int RLOS = A4; 7int FR = 0; 8int FL = 0; 9int 10 RR = 0; 11int RL = 0; 12LiquidCrystal lcd(8, 9, 4, 5, 6, 7); 13void setup() 14{ 15 16 lcd.begin(16, 2); 17 pinMode(FROS, INPUT); 18 pinMode(FLOS, INPUT); 19 20 pinMode(RROS, INPUT); 21 pinMode(RLOS, INPUT); 22 Serial.begin(9600); 23} 24void 25 loop() 26{ 27 FR = analogRead(FROS); 28 Serial.println(FR); 29 FL = analogRead(FLOS); 30 31 RR = analogRead(RROS); 32 RL = analogRead(RLOS); 33 lcd.setCursor(1, 0); 34 35 lcd.print("FR FL RR RL"); 36 if (FR <= 500 && FL <= 500 && RR <= 500 37 && RL <= 500) 38 { 39 lcd.setCursor(1, 1); 40 lcd.print("No Obstacle 41 "); 42 } 43 else if (FR > 500 && FL <= 500 && RR <= 500 && RL <= 500) 44 45 { 46 lcd.setCursor(1, 1); 47 lcd.print("XX "); 48 } 49 50 else if (FR <= 500 && FL <= 500 && RR <= 500 && RL > 500) 51 { 52 lcd.setCursor(1, 53 1); 54 lcd.print(" XX"); 55 } 56 else if (FR <= 500 && FL 57 <= 500 && RR > 500 && RL <= 500) 58 { 59 lcd.setCursor(1, 1); 60 lcd.print(" 61 XX "); 62 } 63 else if (FR <= 500 && FL <= 500 && RR > 500 && 64 RL > 500) 65 { 66 lcd.setCursor(1, 1); 67 lcd.print(" XX XX"); 68 69 } 70 else if (FR <= 500 && FL > 500 && RR <= 500 && RL <= 500) 71 { 72 lcd.setCursor(1, 73 1); 74 lcd.print(" XX "); 75 } 76 else if (FR <= 500 && FL 77 > 500 && RR <= 500 && RL > 500) 78 { 79 lcd.setCursor(1, 1); 80 lcd.print(" 81 XX XX"); 82 } 83 else if (FR <= 500 && FL > 500 && RR > 500 && RL 84 <= 500) 85 { 86 lcd.setCursor(1, 1); 87 lcd.print(" XX XX "); 88 89 } 90 else if (FR <= 500 && FL > 500 && RR > 500 && RL > 500) 91 { 92 lcd.setCursor(1, 93 1); 94 lcd.print(" XX XX XX"); 95 } 96 else if (FR > 500 && FL <= 97 500 && RR <= 500 && RL <= 500) 98 { 99 lcd.setCursor(1, 1); 100 lcd.print("XX 101 "); 102 } 103 else if (FR > 500 && FL <= 500 && RR <= 500 && RL 104 > 500) 105 { 106 lcd.setCursor(1, 1); 107 lcd.print("XX XX"); 108 109 } 110 else if (FR > 500 && FL <= 500 && RR > 500 && RL <= 500) 111 { 112 lcd.setCursor(1, 113 1); 114 lcd.print("XX XX "); 115 } 116 else if (FR > 500 && FL <= 117 500 && RR > 500 && RL > 500) 118 { 119 lcd.setCursor(1, 1); 120 lcd.print("XX 121 XX XX"); 122 } 123 else if (FR > 500 && FL > 500 && RR <= 500 && RL 124 <= 500) 125 { 126 lcd.setCursor(1, 1); 127 lcd.print("XX XX "); 128 129 } 130 else if (FR > 500 && FL > 500 && RR <= 500 && RL > 500) 131 { 132 lcd.setCursor(1, 133 1); 134 lcd.print("XX XX XX"); 135 } 136 else if (FR > 500 && FL > 137 500 && RR > 500 && RL <= 500) 138 { 139 lcd.setCursor(1, 1); 140 lcd.print("XX 141 XX XX "); 142 } 143 else 144 { 145 lcd.setCursor(1, 1); 146 lcd.print("Call 147 Help ...... "); 148 } 149} 150
Downloadable files
Wiring
Wiring
Comments
Only logged in users can leave comments