-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsource.ino
88 lines (66 loc) · 1.63 KB
/
source.ino
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
83
84
85
86
87
88
#define RED 13
#define GREEN 12
#define BLUE 11
#define BUTTON 10
#define BUZZER 6
#include <SoftwareSerial.h>
SoftwareSerial HC05(2, 3);
char Incoming_value = 0;
int buttonState = 0;
void setup()
{
Serial.begin(9600);
HC05.begin(9600);
Serial.begin(9600);
while (!Serial) {
Serial.println("erreur") ; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("bonjour") ;
HC05.println("hello, word");
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(BUTTON, INPUT);
}
void loop()
{
if (HC05.available() > 0)
{
Incoming_value = HC05.read();
Serial.print(Incoming_value);
Serial.print("\n");
if (Incoming_value == '0')
digitalWrite(RED, HIGH);
else if (Incoming_value == '1')
digitalWrite(RED, LOW);
if (Incoming_value == '2')
digitalWrite(GREEN, HIGH);
else if (Incoming_value == '3')
digitalWrite(GREEN, LOW);
if (Incoming_value == '4')
digitalWrite(BLUE, HIGH);
else if (Incoming_value == '5')
digitalWrite(BLUE, LOW);
if (Incoming_value == '6')
{
buttonState = digitalRead(BUTTON);
if (buttonState == LOW)
{
while (buttonState == LOW)
{
tone (BUZZER,450);
buttonState = digitalRead(BUTTON);
digitalWrite(RED, HIGH);
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, HIGH);
delay(1000);
digitalWrite(RED, LOW);
digitalWrite(GREEN, LOW);
digitalWrite(BLUE, LOW);
}
}
}
else if (Incoming_value == '7')
{noTone (BUZZER);}
}
}