-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathArduino Program
More file actions
45 lines (32 loc) · 755 Bytes
/
Arduino Program
File metadata and controls
45 lines (32 loc) · 755 Bytes
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
int incomingByte = 0; // for incoming serial data
int led=10;
int led1=12;
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
if(incomingByte==0)
{
digitalWrite(led,HIGH);
}
else if(incomingByte==1)
{
digitalWrite(led1,HIGH);
}
else if(incomingByte==2)
{
digitalWrite(led,LOW);
}
else if(incomingByte==3)
{
digitalWrite(led1,LOW);
}
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}