0% found this document useful (0 votes)
36 views

Instantly Share Code, Notes, and Snippets.: APC220.ino

The document contains code for an Arduino sketch that receives and sends data to control an LED via an APC220 module. It uses SoftwareSerial to communicate with the module over RX and TX pins at 9600 baud. When it receives an 'l' it turns the LED on, and when it receives a 'q' it turns the LED off. A second section of the code sends those same commands periodically to control the LED remotely.

Uploaded by

Jess Candelearia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Instantly Share Code, Notes, and Snippets.: APC220.ino

The document contains code for an Arduino sketch that receives and sends data to control an LED via an APC220 module. It uses SoftwareSerial to communicate with the module over RX and TX pins at 9600 baud. When it receives an 'l' it turns the LED on, and when it receives a 'q' it turns the LED off. A second section of the code sends those same commands periodically to control the LED remotely.

Uploaded by

Jess Candelearia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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