Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Search… All gists GitHub Sign up for a GitHub account Sign in

Instantly share code, notes, and snippets. Create a gist now

vitorleal / APC220.ino Star 0 Fork 0

Last active 3 years ago

Code Revisions 4 Embed <script src="https://gis Download ZIP

APC220 - Simple case (blink other Arduino Light) -> http://www.dfrobot.com/image/data/TEL0005/APC220_Datasheet.pdf

APC220.ino Raw

1 ////////////////////// RECEIVE DATA \\\\\\\\\\\\\\\\\\\\\\


2 #include <SoftwareSerial.h>
3
4 int RX = 0;
5 int TX = 1;
6 int LED = 13;
7
8 SoftwareSerial apc220(RX, TX);
9
10 void setup() {
11 pinMode(LED, OUTPUT);
12
13 apc220.begin(9600);
14 Serial.begin(9600);
15 }
16
17 void loop() {
18 char msg = apc220.read();
19
20 if (msg == 'l') {
21 Serial.print(msg);
22 digitalWrite(LED, HIGH);
23
24 } else if (msg == 'q') {
25 Serial.print(msg);
26 digitalWrite(LED, LOW);
27 }
28 }
29
30 ////////////////////// SEND DATA \\\\\\\\\\\\\\\\\\\\\\
31 #include <SoftwareSerial.h>
32
33 int RX = 0;
34 int TX = 1;
35
36 SoftwareSerial apc220(RX, TX);
37
38 void setup() {
39 apc220.begin(9600);
40 Serial.begin(9600);
41 }
42
43 void loop() {
44 apc220.println('l');
45 Serial.println('l');
46 delay(2000);
47
48 apc220.println('q');
49 Serial.println('q');
50 delay(2000);
51 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

© 2018 GitHub, Inc. Terms Privacy Security Status Help Contact GitHub API Training Shop Blog About

You might also like