eda79839
Antoine Duquenoy
Upload des sources
|
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
78
79
80
81
82
|
// Pot de fleurs connecté
int STBY = 2;
int PWMA = 6;
int AIN1 = 3;
int AIN2 = 4;
int consigne = -1;
String received;
void setup()
{
pinMode(STBY, OUTPUT);
pinMode(PWMA, OUTPUT);
pinMode(AIN1, OUTPUT);
pinMode(AIN2, OUTPUT);
Serial.begin(115200);
}
void loop() {
int temp_analog = analogRead(A0);
int water_lvl = analogRead(A1);
int hum_purcent = analogRead(A2)/10.23;
received = Serial.readString();
if(received != "")
{
char c = received.charAt(0);
if(c == 'M')
{
consigne = (received.substring(1)).toInt();
Serial.print(received);
delay(50);
}
}
if(hum_purcent < consigne && consigne != -1 )
{
move(255);
}
else
{
stop();
}
String water = "N"+String(water_lvl,DEC);
String temp = "T"+String(temp_analog,DEC);
String hum = "H"+String(hum_purcent,DEC);
Serial.print(water);
delay(300);
Serial.print(hum);
delay(300);
Serial.print(temp);
delay(300);
}
void move(int speed){
digitalWrite(STBY, HIGH); //disable standby
boolean inPin1 = LOW;
boolean inPin2 = HIGH;
digitalWrite(AIN1, inPin1);
digitalWrite(AIN2, inPin2);
analogWrite(PWMA, speed);
}
void stop(){
digitalWrite(STBY, LOW);
}
|