current code

Dependencies:   mbed Motor TextLCD Keypad Frdmlz25 DHT11

Dependents:   Frdmlz25

Committer:
alex123456
Date:
Mon Nov 19 16:21:32 2018 +0000
Branch:
All_done_withoutWIFI
Revision:
7:da7c96261a91
Parent:
6:05022e3201ac
gai

Who changed what in which revision?

UserRevisionLine numberNew contents of line
H_QW 2:8ed2269ab264 1 #include "mbed.h"
alex123456 0:dc0a6c236ec1 2 #include "Dht11.h"
alex123456 0:dc0a6c236ec1 3 #include "TSL2561.h"
alex123456 0:dc0a6c236ec1 4 #include "Keypad.h"
alex123456 0:dc0a6c236ec1 5 #include "TextLCD.h"
alex123456 6:05022e3201ac 6 #include "Motor.h"
alex123456 0:dc0a6c236ec1 7
alex123456 0:dc0a6c236ec1 8 //Setup a new plant1 data
alex123456 6:05022e3201ac 9 float p1_tMin=10.0, p1_tMax=19.0;
alex123456 0:dc0a6c236ec1 10 float p1_lMin=300.0, p1_lMax=50000.0;
alex123456 0:dc0a6c236ec1 11 float p1_hMin=60.0, p1_hMax=70.0;
alex123456 0:dc0a6c236ec1 12 //Setup a new plant2 data
alex123456 0:dc0a6c236ec1 13 float p2_tMin=10.0, p2_tMax=25.0;
alex123456 0:dc0a6c236ec1 14 float p2_lMin=200.0, p2_lMax=50000.0;
alex123456 0:dc0a6c236ec1 15 float p2_hMin=10.0, p2_hMax=40.0;
alex123456 0:dc0a6c236ec1 16 //Setup a new plant3 data
alex123456 0:dc0a6c236ec1 17 float p3_tMin=15.0, p3_tMax=25.0;
alex123456 0:dc0a6c236ec1 18 float p3_lMin=100.0, p3_lMax=50000.0;
alex123456 0:dc0a6c236ec1 19 float p3_hMin=30.0, p3_hMax=70.0;
alex123456 0:dc0a6c236ec1 20
alex123456 6:05022e3201ac 21 Serial pc(PTE0,PTE1);
alex123456 6:05022e3201ac 22 #define _PRINTX(z,x) if(z==1) .printf(x);
alex123456 6:05022e3201ac 23 #define _PRINTLNX(z,x) if(z==1) {.printf(x); .printf("\r\n");}
alex123456 6:05022e3201ac 24 #define _PRINTXY(z,x, y) if(z==1) .printf(x, y);
alex123456 6:05022e3201ac 25 #define _PRINTLNXY(z,x, y) if(z==1) {.printf(x, y); .printf("\r\n");}
alex123456 0:dc0a6c236ec1 26
alex123456 0:dc0a6c236ec1 27
alex123456 0:dc0a6c236ec1 28 //Setup a new plant data
alex123456 0:dc0a6c236ec1 29
alex123456 0:dc0a6c236ec1 30 Dht11 sensor(PTB0);
alex123456 0:dc0a6c236ec1 31 TSL2561 tsl2561(TSL2561_ADDR_FLOAT);// Use the tsl2561 sensor
alex123456 6:05022e3201ac 32 Motor m(PTD2,PTC17,PTC16);//water motor
alex123456 6:05022e3201ac 33 Motor w(PTD0,PTC13,PTC12);//wind motor
alex123456 0:dc0a6c236ec1 34
alex123456 0:dc0a6c236ec1 35 //Setup output
alex123456 6:05022e3201ac 36 DigitalOut output1(PTD3); //lighting
alex123456 6:05022e3201ac 37 DigitalOut m1(PTC13); //Setup water motor output forward
alex123456 6:05022e3201ac 38 DigitalOut m2(PTC12); //Setup water motor output backword
alex123456 6:05022e3201ac 39 DigitalOut w1(PTC17); //Setup wind motor output forward
alex123456 6:05022e3201ac 40 DigitalOut w2(PTC16); //Setup wind motor output backword
alex123456 6:05022e3201ac 41
alex123456 0:dc0a6c236ec1 42 DigitalOut output4(PTD5); //Setup output
alex123456 0:dc0a6c236ec1 43 Keypad KeyInput(PTC4,PTC3,PTC0,PTC7,PTC11,PTC10,PTC6,PTC5);
alex123456 0:dc0a6c236ec1 44 TextLCD lcd(PTB8,PTB9,PTB10,PTB11,PTE2,PTE3,TextLCD::LCD16x2);
alex123456 6:05022e3201ac 45 //float output1=0,w.speed(0),m.speed(0),output4=0;// lighting// watering// ventilation// heating
alex123456 0:dc0a6c236ec1 46
alex123456 0:dc0a6c236ec1 47
alex123456 0:dc0a6c236ec1 48
alex123456 0:dc0a6c236ec1 49
alex123456 0:dc0a6c236ec1 50 int main() {
alex123456 0:dc0a6c236ec1 51 int val_hud;
alex123456 1:c7d87cc6718a 52 char keym,tempkey;
alex123456 0:dc0a6c236ec1 53 uint16_t val_lig;
alex123456 0:dc0a6c236ec1 54 float val_tmp,t;
alex123456 6:05022e3201ac 55 m1=1;
alex123456 6:05022e3201ac 56 m2=0;
alex123456 6:05022e3201ac 57 w1=1;
alex123456 6:05022e3201ac 58 w2=0;
alex123456 6:05022e3201ac 59
alex123456 6:05022e3201ac 60 // int output1,output2,m.speed,output4;
alex123456 0:dc0a6c236ec1 61
alex123456 0:dc0a6c236ec1 62
alex123456 0:dc0a6c236ec1 63 lcd.printf("-----START------");
alex123456 0:dc0a6c236ec1 64 wait(2);
alex123456 0:dc0a6c236ec1 65 lcd.printf("WELCOME TO 6711");
alex123456 0:dc0a6c236ec1 66 wait(3);
alex123456 0:dc0a6c236ec1 67
alex123456 0:dc0a6c236ec1 68
alex123456 0:dc0a6c236ec1 69
alex123456 0:dc0a6c236ec1 70 while (1) {
alex123456 0:dc0a6c236ec1 71 lcd.printf("Please input the No. of plant");
alex123456 0:dc0a6c236ec1 72 wait(0.2);
alex123456 0:dc0a6c236ec1 73 keym=KeyInput.ReadKey();
alex123456 1:c7d87cc6718a 74 tempkey=keym;
alex123456 0:dc0a6c236ec1 75 lcd.cls();
alex123456 0:dc0a6c236ec1 76 if (keym!='\0') {
alex123456 0:dc0a6c236ec1 77 lcd.printf("The type of plant is %c",keym);
alex123456 0:dc0a6c236ec1 78 wait(3);
alex123456 0:dc0a6c236ec1 79 lcd.cls();;
alex123456 0:dc0a6c236ec1 80
alex123456 0:dc0a6c236ec1 81 //while(keym!='0') {
alex123456 0:dc0a6c236ec1 82 while(1) {
alex123456 1:c7d87cc6718a 83 keym=KeyInput.ReadKey(); // input a key see if it is the key to trun out
alex123456 1:c7d87cc6718a 84 if (keym=='\0'){
alex123456 1:c7d87cc6718a 85 keym=tempkey;
alex123456 1:c7d87cc6718a 86 }
alex123456 1:c7d87cc6718a 87 else if (keym!='\0') {
alex123456 1:c7d87cc6718a 88 lcd.printf("If you want reset, plesee input zer0 !");
alex123456 1:c7d87cc6718a 89 keym=KeyInput.ReadKey();
alex123456 1:c7d87cc6718a 90 if (keym=='0'){
alex123456 1:c7d87cc6718a 91 break;
alex123456 1:c7d87cc6718a 92 }
alex123456 0:dc0a6c236ec1 93
alex123456 1:c7d87cc6718a 94 }
alex123456 0:dc0a6c236ec1 95
alex123456 0:dc0a6c236ec1 96 // get temperature and humidity data from sensor
alex123456 0:dc0a6c236ec1 97 sensor.read();
alex123456 0:dc0a6c236ec1 98 t=sensor.getFahrenheit();
alex123456 0:dc0a6c236ec1 99 val_tmp=(t-32)/1.8;
alex123456 0:dc0a6c236ec1 100 val_hud=sensor.getHumidity();
alex123456 0:dc0a6c236ec1 101 lcd.printf("T: %2.1fC\n", val_tmp);
alex123456 0:dc0a6c236ec1 102 lcd.printf("H: %d%%\n",val_hud);
alex123456 0:dc0a6c236ec1 103 wait(3);
alex123456 0:dc0a6c236ec1 104 lcd.cls();
alex123456 0:dc0a6c236ec1 105
alex123456 0:dc0a6c236ec1 106 // get light data
alex123456 0:dc0a6c236ec1 107 val_lig = tsl2561.getLuminosity(TSL2561_VISIBLE);
alex123456 0:dc0a6c236ec1 108 lcd.printf("Illu is:%d Lux\n",val_lig);
alex123456 0:dc0a6c236ec1 109 wait(2);
alex123456 0:dc0a6c236ec1 110 lcd.cls();
alex123456 1:c7d87cc6718a 111
alex123456 0:dc0a6c236ec1 112 // compare data
alex123456 6:05022e3201ac 113 //lcd.printf("key is:%c \n",keym);
alex123456 6:05022e3201ac 114 //wait(2);
alex123456 0:dc0a6c236ec1 115 if (keym=='1') {
alex123456 0:dc0a6c236ec1 116 if (val_tmp>=p1_tMin && val_tmp<=p1_tMax) {
alex123456 0:dc0a6c236ec1 117 if (val_hud>=p1_hMin && val_hud<=p1_hMax) {
alex123456 0:dc0a6c236ec1 118 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 0:dc0a6c236ec1 119 output1=0;
alex123456 6:05022e3201ac 120 w.speed(0);
alex123456 6:05022e3201ac 121 m.speed(0);
alex123456 0:dc0a6c236ec1 122 output4=0;
alex123456 0:dc0a6c236ec1 123 }
alex123456 0:dc0a6c236ec1 124 else if (val_lig<p1_lMin){
alex123456 0:dc0a6c236ec1 125 output1=1;
alex123456 6:05022e3201ac 126 w.speed(0);
alex123456 6:05022e3201ac 127 m.speed(0);
alex123456 0:dc0a6c236ec1 128 output4=0;
alex123456 0:dc0a6c236ec1 129 }
alex123456 0:dc0a6c236ec1 130 }
alex123456 0:dc0a6c236ec1 131
alex123456 0:dc0a6c236ec1 132
alex123456 0:dc0a6c236ec1 133 else if (val_hud<=p1_hMin ) {
alex123456 0:dc0a6c236ec1 134 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 0:dc0a6c236ec1 135 output1=0;
alex123456 6:05022e3201ac 136 w.speed(0.3);
alex123456 6:05022e3201ac 137 m.speed(1);
alex123456 0:dc0a6c236ec1 138 output4=0;
alex123456 0:dc0a6c236ec1 139 }
alex123456 0:dc0a6c236ec1 140 else if (val_lig<p1_lMin){
alex123456 0:dc0a6c236ec1 141 output1=1;
alex123456 6:05022e3201ac 142 w.speed(0.5);
alex123456 6:05022e3201ac 143 m.speed(1);
alex123456 0:dc0a6c236ec1 144 output4=0;
alex123456 0:dc0a6c236ec1 145 }
alex123456 0:dc0a6c236ec1 146 }
alex123456 0:dc0a6c236ec1 147 else {
alex123456 0:dc0a6c236ec1 148 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 0:dc0a6c236ec1 149 output1=0;
alex123456 6:05022e3201ac 150 w.speed(1);
alex123456 6:05022e3201ac 151 m.speed(0);
alex123456 0:dc0a6c236ec1 152 output4=0;
alex123456 0:dc0a6c236ec1 153 }
alex123456 0:dc0a6c236ec1 154 else if (val_lig<=p1_lMin){
alex123456 0:dc0a6c236ec1 155 output1=1;
alex123456 7:da7c96261a91 156 w.speed(0.9);
alex123456 7:da7c96261a91 157 m.speed(0.7);
alex123456 0:dc0a6c236ec1 158 output4=0;
alex123456 0:dc0a6c236ec1 159 }
alex123456 0:dc0a6c236ec1 160 }
alex123456 0:dc0a6c236ec1 161
alex123456 0:dc0a6c236ec1 162
alex123456 0:dc0a6c236ec1 163 }
alex123456 0:dc0a6c236ec1 164 else if (val_tmp<=p1_tMin){
alex123456 0:dc0a6c236ec1 165 if (val_hud>=p1_hMin && val_hud<=p1_hMax){
alex123456 0:dc0a6c236ec1 166 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 0:dc0a6c236ec1 167 output1=0;
alex123456 6:05022e3201ac 168 w.speed(0);
alex123456 6:05022e3201ac 169 m.speed(0);
alex123456 0:dc0a6c236ec1 170 output4=1;
alex123456 0:dc0a6c236ec1 171 }
alex123456 0:dc0a6c236ec1 172 else if (val_lig<=p1_lMin){
alex123456 0:dc0a6c236ec1 173 output1=1;
alex123456 6:05022e3201ac 174 w.speed(0);
alex123456 6:05022e3201ac 175 m.speed(0);
alex123456 0:dc0a6c236ec1 176 output4=1;
alex123456 0:dc0a6c236ec1 177 }
alex123456 0:dc0a6c236ec1 178 }
alex123456 0:dc0a6c236ec1 179
alex123456 0:dc0a6c236ec1 180 else if (val_hud<=p1_hMin ) {
alex123456 0:dc0a6c236ec1 181 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 0:dc0a6c236ec1 182 output1=0;
alex123456 7:da7c96261a91 183 w.speed(0.5);
alex123456 6:05022e3201ac 184 m.speed(1);
alex123456 0:dc0a6c236ec1 185 output4=1;
alex123456 0:dc0a6c236ec1 186 }
alex123456 0:dc0a6c236ec1 187 else if (val_lig<=p1_lMin){
alex123456 0:dc0a6c236ec1 188 output1=1;
alex123456 6:05022e3201ac 189 w.speed(0);
alex123456 6:05022e3201ac 190 m.speed(1);
alex123456 0:dc0a6c236ec1 191 output4=1;
alex123456 0:dc0a6c236ec1 192 }
alex123456 0:dc0a6c236ec1 193 }
alex123456 0:dc0a6c236ec1 194 else {
alex123456 0:dc0a6c236ec1 195 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 0:dc0a6c236ec1 196 output1=0;
alex123456 6:05022e3201ac 197 w.speed(0.5);
alex123456 6:05022e3201ac 198 m.speed(0);
alex123456 0:dc0a6c236ec1 199 output4=1;
alex123456 0:dc0a6c236ec1 200 }
alex123456 0:dc0a6c236ec1 201 else if (val_lig<=p1_lMin){
alex123456 0:dc0a6c236ec1 202 output1=1;
alex123456 6:05022e3201ac 203 w.speed(0.5);
alex123456 6:05022e3201ac 204 m.speed(0);
alex123456 0:dc0a6c236ec1 205 output4=1;
alex123456 0:dc0a6c236ec1 206 }
alex123456 0:dc0a6c236ec1 207 }
alex123456 0:dc0a6c236ec1 208 }
alex123456 0:dc0a6c236ec1 209
alex123456 0:dc0a6c236ec1 210
alex123456 0:dc0a6c236ec1 211
alex123456 0:dc0a6c236ec1 212 else{
alex123456 0:dc0a6c236ec1 213 if (val_hud>=p1_hMin && val_hud<=p1_hMax){
alex123456 0:dc0a6c236ec1 214 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 0:dc0a6c236ec1 215 output1=0;
alex123456 6:05022e3201ac 216 w.speed(0.8);
alex123456 6:05022e3201ac 217 m.speed(1);
alex123456 0:dc0a6c236ec1 218 output4=0;
alex123456 0:dc0a6c236ec1 219 }
alex123456 0:dc0a6c236ec1 220 else if (val_lig<=p1_lMin){
alex123456 0:dc0a6c236ec1 221 output1=1;
alex123456 6:05022e3201ac 222 w.speed(0.4);
alex123456 6:05022e3201ac 223 m.speed(1);
alex123456 0:dc0a6c236ec1 224 output4=0;
alex123456 0:dc0a6c236ec1 225 }
alex123456 0:dc0a6c236ec1 226 }
alex123456 0:dc0a6c236ec1 227
alex123456 0:dc0a6c236ec1 228 else if (val_hud<=p1_hMin ) {
alex123456 0:dc0a6c236ec1 229 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 0:dc0a6c236ec1 230 output1=0;
alex123456 6:05022e3201ac 231 w.speed(0.3);
alex123456 6:05022e3201ac 232 m.speed(1);
alex123456 0:dc0a6c236ec1 233 output4=0;
alex123456 0:dc0a6c236ec1 234 }
alex123456 0:dc0a6c236ec1 235 else if (val_lig<=p1_lMin){
alex123456 0:dc0a6c236ec1 236 output1=1;
alex123456 6:05022e3201ac 237 w.speed(0.5);
alex123456 6:05022e3201ac 238 m.speed(1);
alex123456 0:dc0a6c236ec1 239 output4=0;
alex123456 0:dc0a6c236ec1 240 }
alex123456 0:dc0a6c236ec1 241 }
alex123456 0:dc0a6c236ec1 242 else{
alex123456 0:dc0a6c236ec1 243 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 0:dc0a6c236ec1 244 output1=0;
alex123456 6:05022e3201ac 245 w.speed(1);
alex123456 6:05022e3201ac 246 m.speed(0);
alex123456 0:dc0a6c236ec1 247 output4=0;
alex123456 0:dc0a6c236ec1 248 }
alex123456 0:dc0a6c236ec1 249 else if (val_lig<=p1_lMin){
alex123456 0:dc0a6c236ec1 250 output1=1;
alex123456 6:05022e3201ac 251 w.speed(1);
alex123456 6:05022e3201ac 252 m.speed(0);
alex123456 0:dc0a6c236ec1 253 output4=0;
alex123456 0:dc0a6c236ec1 254 }
alex123456 0:dc0a6c236ec1 255 }
alex123456 0:dc0a6c236ec1 256 }
alex123456 0:dc0a6c236ec1 257
alex123456 1:c7d87cc6718a 258 }
alex123456 1:c7d87cc6718a 259 //-------------------------- sceond type-----------------------------------------
alex123456 1:c7d87cc6718a 260 else if (keym=='2') {
alex123456 1:c7d87cc6718a 261 if (val_tmp>=p2_tMin && val_tmp<=p2_tMax) {
alex123456 1:c7d87cc6718a 262 if (val_hud>=p2_hMin && val_hud<=p2_hMax) {
alex123456 1:c7d87cc6718a 263 if (val_lig>=p2_lMin && val_lig<=p2_lMax) {
alex123456 1:c7d87cc6718a 264 output1=0;
alex123456 6:05022e3201ac 265 w.speed(0);
alex123456 6:05022e3201ac 266 m.speed(0);
alex123456 1:c7d87cc6718a 267 output4=0;
alex123456 1:c7d87cc6718a 268 }
alex123456 1:c7d87cc6718a 269 else if (val_lig<p2_lMin){
alex123456 1:c7d87cc6718a 270 output1=1;
alex123456 6:05022e3201ac 271 w.speed(0);
alex123456 6:05022e3201ac 272 m.speed(0);
alex123456 1:c7d87cc6718a 273 output4=0;
alex123456 1:c7d87cc6718a 274 }
alex123456 1:c7d87cc6718a 275 }
alex123456 1:c7d87cc6718a 276
alex123456 1:c7d87cc6718a 277
alex123456 1:c7d87cc6718a 278 else if (val_hud<=p2_hMin ) {
alex123456 1:c7d87cc6718a 279 if (val_lig>=p2_lMin && val_lig<=p2_lMax) {
alex123456 1:c7d87cc6718a 280 output1=0;
alex123456 6:05022e3201ac 281 w.speed(0);
alex123456 6:05022e3201ac 282 m.speed(1);
alex123456 1:c7d87cc6718a 283 output4=0;
alex123456 1:c7d87cc6718a 284 }
alex123456 1:c7d87cc6718a 285 else if (val_lig<p2_lMin){
alex123456 1:c7d87cc6718a 286 output1=1;
alex123456 6:05022e3201ac 287 w.speed(0);
alex123456 6:05022e3201ac 288 m.speed(1);
alex123456 1:c7d87cc6718a 289 output4=0;
alex123456 1:c7d87cc6718a 290 }
alex123456 1:c7d87cc6718a 291 }
alex123456 1:c7d87cc6718a 292 else {
alex123456 1:c7d87cc6718a 293 if (val_lig>=p2_lMin && val_lig<=p2_lMax) {
alex123456 1:c7d87cc6718a 294 output1=0;
alex123456 6:05022e3201ac 295 w.speed(0.5);
alex123456 6:05022e3201ac 296 m.speed(0);
alex123456 1:c7d87cc6718a 297 output4=0;
alex123456 1:c7d87cc6718a 298 }
alex123456 1:c7d87cc6718a 299 else if (val_lig<=p1_lMin){
alex123456 1:c7d87cc6718a 300 output1=1;
alex123456 6:05022e3201ac 301 w.speed(0.5);
alex123456 6:05022e3201ac 302 m.speed(0);
alex123456 1:c7d87cc6718a 303 output4=0;
alex123456 1:c7d87cc6718a 304 }
alex123456 1:c7d87cc6718a 305 }
alex123456 1:c7d87cc6718a 306
alex123456 1:c7d87cc6718a 307
alex123456 1:c7d87cc6718a 308 }
alex123456 1:c7d87cc6718a 309 else if (val_tmp<=p1_tMin){
alex123456 1:c7d87cc6718a 310 if (val_hud>=p2_hMin && val_hud<=p2_hMax){
alex123456 1:c7d87cc6718a 311 if (val_lig>=p2_lMin && val_lig<=p2_lMax) {
alex123456 1:c7d87cc6718a 312 output1=0;
alex123456 6:05022e3201ac 313 w.speed(0);
alex123456 6:05022e3201ac 314 m.speed(0);
alex123456 1:c7d87cc6718a 315 output4=1;
alex123456 1:c7d87cc6718a 316 }
alex123456 1:c7d87cc6718a 317 else if (val_lig<=p2_lMin){
alex123456 1:c7d87cc6718a 318 output1=1;
alex123456 6:05022e3201ac 319 w.speed(0);
alex123456 6:05022e3201ac 320 m.speed(0);
alex123456 1:c7d87cc6718a 321 output4=1;
alex123456 1:c7d87cc6718a 322 }
alex123456 1:c7d87cc6718a 323 }
alex123456 1:c7d87cc6718a 324
alex123456 1:c7d87cc6718a 325 else if (val_hud<=p2_hMin ) {
alex123456 1:c7d87cc6718a 326 if (val_lig>=p2_lMin && val_lig<=p2_lMax) {
alex123456 1:c7d87cc6718a 327 output1=0;
alex123456 6:05022e3201ac 328 w.speed(0);
alex123456 6:05022e3201ac 329 m.speed(1);
alex123456 1:c7d87cc6718a 330 output4=1;
alex123456 1:c7d87cc6718a 331 }
alex123456 1:c7d87cc6718a 332 else if (val_lig<=p1_lMin){
alex123456 1:c7d87cc6718a 333 output1=1;
alex123456 6:05022e3201ac 334 w.speed(0);
alex123456 6:05022e3201ac 335 m.speed(1);
alex123456 1:c7d87cc6718a 336 output4=1;
alex123456 1:c7d87cc6718a 337 }
alex123456 1:c7d87cc6718a 338 }
alex123456 1:c7d87cc6718a 339 else {
alex123456 1:c7d87cc6718a 340 if (val_lig>=p2_lMin && val_lig<=p2_lMax) {
alex123456 1:c7d87cc6718a 341 output1=0;
alex123456 6:05022e3201ac 342 w.speed(0.5);
alex123456 6:05022e3201ac 343 m.speed(0);
alex123456 1:c7d87cc6718a 344 output4=1;
alex123456 1:c7d87cc6718a 345 }
alex123456 1:c7d87cc6718a 346 else if (val_lig<=p2_lMin){
alex123456 1:c7d87cc6718a 347 output1=1;
alex123456 6:05022e3201ac 348 w.speed(0.5);
alex123456 6:05022e3201ac 349 m.speed(0);
alex123456 1:c7d87cc6718a 350 output4=1;
alex123456 1:c7d87cc6718a 351 }
alex123456 1:c7d87cc6718a 352 }
alex123456 1:c7d87cc6718a 353 }
alex123456 1:c7d87cc6718a 354
alex123456 1:c7d87cc6718a 355
alex123456 1:c7d87cc6718a 356
alex123456 1:c7d87cc6718a 357 else{
alex123456 1:c7d87cc6718a 358 if (val_hud>=p2_hMin && val_hud<=p2_hMax){
alex123456 1:c7d87cc6718a 359 if (val_lig>=p2_lMin && val_lig<=p2_lMax) {
alex123456 1:c7d87cc6718a 360 output1=0;
alex123456 6:05022e3201ac 361 w.speed(0.5);
alex123456 6:05022e3201ac 362 m.speed(1);
alex123456 1:c7d87cc6718a 363 output4=0;
alex123456 1:c7d87cc6718a 364 }
alex123456 1:c7d87cc6718a 365 else if (val_lig<=p2_lMin){
alex123456 1:c7d87cc6718a 366 output1=1;
alex123456 6:05022e3201ac 367 w.speed(0.5);
alex123456 6:05022e3201ac 368 m.speed(1);
alex123456 1:c7d87cc6718a 369 output4=0;
alex123456 1:c7d87cc6718a 370 }
alex123456 1:c7d87cc6718a 371 }
alex123456 1:c7d87cc6718a 372
alex123456 1:c7d87cc6718a 373 else if (val_hud<=p2_hMin ) {
alex123456 1:c7d87cc6718a 374 if (val_lig>=p2_lMin && val_lig<=p2_lMax) {
alex123456 1:c7d87cc6718a 375 output1=0;
alex123456 6:05022e3201ac 376 w.speed(0.5);
alex123456 6:05022e3201ac 377 m.speed(1);
alex123456 1:c7d87cc6718a 378 output4=0;
alex123456 1:c7d87cc6718a 379 }
alex123456 1:c7d87cc6718a 380 else if (val_lig<=p2_lMin){
alex123456 1:c7d87cc6718a 381 output1=1;
alex123456 6:05022e3201ac 382 w.speed(0.5);
alex123456 6:05022e3201ac 383 m.speed(1);
alex123456 1:c7d87cc6718a 384 output4=0;
alex123456 1:c7d87cc6718a 385 }
alex123456 1:c7d87cc6718a 386 }
alex123456 1:c7d87cc6718a 387 else{
alex123456 1:c7d87cc6718a 388 if (val_lig>=p2_lMin && val_lig<=p2_lMax) {
alex123456 1:c7d87cc6718a 389 output1=0;
alex123456 6:05022e3201ac 390 w.speed(0.5);
alex123456 6:05022e3201ac 391 m.speed(0);
alex123456 1:c7d87cc6718a 392 output4=0;
alex123456 1:c7d87cc6718a 393 }
alex123456 1:c7d87cc6718a 394 else if (val_lig<=p2_lMin){
alex123456 1:c7d87cc6718a 395 output1=1;
alex123456 6:05022e3201ac 396 w.speed(0.5);
alex123456 6:05022e3201ac 397 m.speed(0);
alex123456 1:c7d87cc6718a 398 output4=0;
alex123456 1:c7d87cc6718a 399 }
alex123456 1:c7d87cc6718a 400 }
alex123456 1:c7d87cc6718a 401 }
alex123456 1:c7d87cc6718a 402 }
alex123456 1:c7d87cc6718a 403 //-------------------------- Third type-----------------------------------------
alex123456 1:c7d87cc6718a 404 else{
alex123456 1:c7d87cc6718a 405 if (val_tmp>=p1_tMin && val_tmp<=p1_tMax) {
alex123456 1:c7d87cc6718a 406 if (val_hud>=p1_hMin && val_hud<=p1_hMax) {
alex123456 1:c7d87cc6718a 407 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 1:c7d87cc6718a 408 output1=0;
alex123456 6:05022e3201ac 409 w.speed(0);
alex123456 6:05022e3201ac 410 m.speed(0);
alex123456 1:c7d87cc6718a 411 output4=0;
alex123456 1:c7d87cc6718a 412 }
alex123456 1:c7d87cc6718a 413 else if (val_lig<p1_lMin){
alex123456 1:c7d87cc6718a 414 output1=1;
alex123456 6:05022e3201ac 415 w.speed(0);
alex123456 6:05022e3201ac 416 m.speed(0);
alex123456 1:c7d87cc6718a 417 output4=0;
alex123456 1:c7d87cc6718a 418 }
alex123456 1:c7d87cc6718a 419 }
alex123456 1:c7d87cc6718a 420
alex123456 1:c7d87cc6718a 421
alex123456 1:c7d87cc6718a 422 else if (val_hud<=p1_hMin ) {
alex123456 1:c7d87cc6718a 423 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 1:c7d87cc6718a 424 output1=0;
alex123456 6:05022e3201ac 425 w.speed(0);
alex123456 6:05022e3201ac 426 m.speed(1);
alex123456 1:c7d87cc6718a 427 output4=0;
alex123456 1:c7d87cc6718a 428 }
alex123456 1:c7d87cc6718a 429 else if (val_lig<p1_lMin){
alex123456 1:c7d87cc6718a 430 output1=1;
alex123456 6:05022e3201ac 431 w.speed(0);
alex123456 6:05022e3201ac 432 m.speed(1);
alex123456 1:c7d87cc6718a 433 output4=0;
alex123456 1:c7d87cc6718a 434 }
alex123456 1:c7d87cc6718a 435 }
alex123456 1:c7d87cc6718a 436 else {
alex123456 1:c7d87cc6718a 437 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 1:c7d87cc6718a 438 output1=0;
alex123456 6:05022e3201ac 439 w.speed(0.5);
alex123456 6:05022e3201ac 440 m.speed(0);
alex123456 1:c7d87cc6718a 441 output4=0;
alex123456 1:c7d87cc6718a 442 }
alex123456 1:c7d87cc6718a 443 else if (val_lig<=p1_lMin){
alex123456 1:c7d87cc6718a 444 output1=1;
alex123456 6:05022e3201ac 445 w.speed(0.5);
alex123456 6:05022e3201ac 446 m.speed(0);
alex123456 1:c7d87cc6718a 447 output4=0;
alex123456 1:c7d87cc6718a 448 }
alex123456 1:c7d87cc6718a 449 }
alex123456 1:c7d87cc6718a 450
alex123456 1:c7d87cc6718a 451
alex123456 1:c7d87cc6718a 452 }
alex123456 1:c7d87cc6718a 453 else if (val_tmp<=p1_tMin){
alex123456 1:c7d87cc6718a 454 if (val_hud>=p1_hMin && val_hud<=p1_hMax){
alex123456 1:c7d87cc6718a 455 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 1:c7d87cc6718a 456 output1=0;
alex123456 6:05022e3201ac 457 w.speed(0);
alex123456 6:05022e3201ac 458 m.speed(0);
alex123456 1:c7d87cc6718a 459 output4=1;
alex123456 1:c7d87cc6718a 460 }
alex123456 1:c7d87cc6718a 461 else if (val_lig<=p1_lMin){
alex123456 1:c7d87cc6718a 462 output1=1;
alex123456 6:05022e3201ac 463 w.speed(0);
alex123456 6:05022e3201ac 464 m.speed(0);
alex123456 1:c7d87cc6718a 465 output4=1;
alex123456 1:c7d87cc6718a 466 }
alex123456 1:c7d87cc6718a 467 }
alex123456 1:c7d87cc6718a 468
alex123456 1:c7d87cc6718a 469 else if (val_hud<=p1_hMin ) {
alex123456 1:c7d87cc6718a 470 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 1:c7d87cc6718a 471 output1=0;
alex123456 6:05022e3201ac 472 w.speed(0);
alex123456 6:05022e3201ac 473 m.speed(1);
alex123456 1:c7d87cc6718a 474 output4=1;
alex123456 1:c7d87cc6718a 475 }
alex123456 1:c7d87cc6718a 476 else if (val_lig<=p1_lMin){
alex123456 1:c7d87cc6718a 477 output1=1;
alex123456 6:05022e3201ac 478 w.speed(0);
alex123456 6:05022e3201ac 479 m.speed(1);
alex123456 1:c7d87cc6718a 480 output4=1;
alex123456 1:c7d87cc6718a 481 }
alex123456 1:c7d87cc6718a 482 }
alex123456 1:c7d87cc6718a 483 else {
alex123456 1:c7d87cc6718a 484 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 1:c7d87cc6718a 485 output1=0;
alex123456 6:05022e3201ac 486 w.speed(0.5);
alex123456 6:05022e3201ac 487 m.speed(0);
alex123456 1:c7d87cc6718a 488 output4=1;
alex123456 1:c7d87cc6718a 489 }
alex123456 1:c7d87cc6718a 490 else if (val_lig<=p1_lMin){
alex123456 1:c7d87cc6718a 491 output1=1;
alex123456 6:05022e3201ac 492 w.speed(0.5);
alex123456 6:05022e3201ac 493 m.speed(0);
alex123456 1:c7d87cc6718a 494 output4=1;
alex123456 1:c7d87cc6718a 495 }
alex123456 1:c7d87cc6718a 496 }
alex123456 1:c7d87cc6718a 497 }
alex123456 1:c7d87cc6718a 498
alex123456 1:c7d87cc6718a 499
alex123456 1:c7d87cc6718a 500
alex123456 1:c7d87cc6718a 501 else{
alex123456 1:c7d87cc6718a 502 if (val_hud>=p1_hMin && val_hud<=p1_hMax){
alex123456 1:c7d87cc6718a 503 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 1:c7d87cc6718a 504 output1=0;
alex123456 6:05022e3201ac 505 w.speed(0.5);
alex123456 6:05022e3201ac 506 m.speed(1);
alex123456 1:c7d87cc6718a 507 output4=0;
alex123456 1:c7d87cc6718a 508 }
alex123456 1:c7d87cc6718a 509 else if (val_lig<=p1_lMin){
alex123456 1:c7d87cc6718a 510 output1=1;
alex123456 6:05022e3201ac 511 w.speed(0.5);
alex123456 6:05022e3201ac 512 m.speed(1);
alex123456 1:c7d87cc6718a 513 output4=0;
alex123456 1:c7d87cc6718a 514 }
alex123456 1:c7d87cc6718a 515 }
alex123456 1:c7d87cc6718a 516
alex123456 1:c7d87cc6718a 517 else if (val_hud<=p1_hMin ) {
alex123456 1:c7d87cc6718a 518 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 1:c7d87cc6718a 519 output1=0;
alex123456 6:05022e3201ac 520 w.speed(0.5);
alex123456 6:05022e3201ac 521 m.speed(1);
alex123456 1:c7d87cc6718a 522 output4=0;
alex123456 1:c7d87cc6718a 523 }
alex123456 1:c7d87cc6718a 524 else if (val_lig<=p1_lMin){
alex123456 1:c7d87cc6718a 525 output1=1;
alex123456 6:05022e3201ac 526 w.speed(0.5);
alex123456 6:05022e3201ac 527 m.speed(1);
alex123456 1:c7d87cc6718a 528 output4=0;
alex123456 1:c7d87cc6718a 529 }
alex123456 1:c7d87cc6718a 530 }
alex123456 1:c7d87cc6718a 531 else{
alex123456 1:c7d87cc6718a 532 if (val_lig>=p1_lMin && val_lig<=p1_lMax) {
alex123456 1:c7d87cc6718a 533 output1=0;
alex123456 6:05022e3201ac 534 w.speed(0.5);
alex123456 6:05022e3201ac 535 m.speed(0);
alex123456 1:c7d87cc6718a 536 output4=0;
alex123456 1:c7d87cc6718a 537 }
alex123456 1:c7d87cc6718a 538 else if (val_lig<=p1_lMin){
alex123456 1:c7d87cc6718a 539 output1=1;
alex123456 6:05022e3201ac 540 w.speed(0.5);
alex123456 6:05022e3201ac 541 m.speed(0);
alex123456 1:c7d87cc6718a 542 output4=0;
alex123456 1:c7d87cc6718a 543 }
alex123456 1:c7d87cc6718a 544 }
alex123456 1:c7d87cc6718a 545 }
alex123456 1:c7d87cc6718a 546 }
alex123456 0:dc0a6c236ec1 547
alex123456 1:c7d87cc6718a 548
alex123456 0:dc0a6c236ec1 549 }
alex123456 0:dc0a6c236ec1 550 }
alex123456 0:dc0a6c236ec1 551 }
alex123456 0:dc0a6c236ec1 552 }