Blame view

Programme_arduino_maitre 1.35 KB
d4a6dcca   sblas   Ajout du programm...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  
  #include <SoftwareSerial.h>
  
  SoftwareSerial soft1(10,11);
  SoftwareSerial soft2(8,9);
  
  const int in1 = A0;
  const int out1 = A1;
  
  int envoi = 0;
  String msg="";
  int fin1=0;
  
  void setup()
  {
    Serial.begin(9600);
    soft1.begin(9600);
    soft2.begin(38400);
    pinMode(in1,INPUT);
    pinMode(out1,OUTPUT);
    digitalWrite(out1,LOW);
  }
  
  void loop()
  {
    String msg_tmp="";
    String prim = "+\n";
    char inByte = 'a';
    int tps,tps2;
    int timeout=0,timeout2=0;
    int validation = 0;
    if(fin1==0){
    while(envoi==0){
          digitalWrite(out1,HIGH);
          if(digitalRead(in1)==HIGH){
            soft1.print(prim);
            soft1.flush();
            envoi = 1;
            Serial.println("rogt");
          }
    }
  
      digitalWrite(out1,LOW);
      tps =millis();
    while(timeout <10000){
      timeout = millis() - tps;
      if(digitalRead(in1)==HIGH){
      digitalWrite(out1,HIGH);
      soft1.listen();
      tps2=millis();
      if(soft1.available()>0){
      if(timeout2<50){
      inByte='a';
      while(inByte != '\n'){
        inByte = soft1.read();
        delay(10);
        if(inByte != '\n'){
          msg_tmp += inByte;
          if(inByte == 0x7A){
            msg += msg_tmp;
          }
        }
        }
        Serial.print(msg_tmp);
        }
      }
      }
        msg_tmp="";
        digitalWrite(out1, LOW);
    }
    msg += "\n\n\r";
    Serial.println("blorp");
    Serial.print(msg);
    soft2.print(msg);
    fin1=1;
   }
  }