안녕하세요. 죄송하지만 이 코드 주석즘 한국어로 변역 시켜주실 수있나요.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include "WizFi250.h"
LiquidCrystal_I2C lcd(0x27, 16, 2); // I2C LCD
char ssid[] = "SSID"; // your network SSID (name)
char pass[] = "PASS"; // your network password
int status = WL_IDLE_STATUS; // the Wifi radio's status
//Ubidots information
#define APIKEY "APIKEY"
#define ROUTEID "ROUTEID"
#define STATIONID "STATIONID"
char server[] = "openapi.gbis.go.kr";
boolean readingVal;
boolean readingVal1;
boolean readingVal2;
boolean readingVal3;
boolean viewData;
boolean getIsConnected = false;
String locationNo1;
String locationNo2;
String predictTime1;
String predictTime2;
String rcvbuf;
// Initialize the Ethernet client object
WiFiClient client;
void httpRequest();
void printWifiStatus();
void setup()
{
// initialize serial for debugging
Serial.begin(115200);
Serial.println(F("\r\nSerial Init"));
pinMode(7, INPUT_PULLUP);
pinMode(6, INPUT_PULLUP);
pinMode(5, OUTPUT);
lcd.begin();
lcd.backlight();
lcd.print("Bus Info System");
lcd.setCursor(0, 1);
lcd.print(" 1500-2 Bus");
WiFi.init();
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue
while (true);
}
// attempt to connect to WiFi network
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network
status = WiFi.begin(ssid, pass);
}
Serial.println("You're connected to the network");
printWifiStatus();
}
void loop() {
// if there's incoming data from the net connection send it out the serial port
// this is for debugging purposes only
while (client.available()) {
digitalWrite(5,HIGH); //LED ON
char c = client.read();
if ( c != NULL ) {
if (rcvbuf.length() > 130)
rcvbuf = "";
rcvbuf += c;
Serial.write(c);
if (rcvbuf.endsWith("<locationNo1>")) {
readingVal = true;
locationNo1 = "";
}
else if (rcvbuf.endsWith("<locationNo2>")) {
readingVal1 = true;
locationNo2 = "";
}
else if (rcvbuf.endsWith("<predictTime1>")) {
readingVal2 = true;
predictTime1 = "";
}
else if (rcvbuf.endsWith("<predictTime2>")) {
readingVal3 = true;
predictTime2 = "";
}
if (readingVal)
dataParser(c, locationNo1, readingVal);
else if (readingVal1)
dataParser(c, locationNo2, readingVal1);
else if (readingVal2)
dataParser(c, predictTime1, readingVal2);
else if (readingVal3)
dataParser(c, predictTime2, readingVal3);
}
digitalWrite(5,LOW); //LED OFF
}
//if (millis() - lastConnectionTime > postingInterval) {
if (!digitalRead(7)) {
httpRequest();
}
if (!digitalRead(6)) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("[1st] after ");
lcd.print(predictTime1);
lcd.print("m");
lcd.setCursor(0, 1);
lcd.print(locationNo1);
lcd.print(" stop(s) away.");
delay(5000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("[2nd] after ");
lcd.print(predictTime2);
lcd.print("m");
lcd.setCursor(0, 1);
lcd.print(locationNo2);
lcd.print(" stop(s) away.");
delay(5000);
}
rcvbuf = "";
}
// this method makes a HTTP connection to the server
void httpRequest() {
Serial.println();
// close any connection before send a new request
// this will free the socket on the WiFi shield
client.stop();
// if there's a successful connection
if (client.connect(server, 80)) {
Serial.println("Connecting...");
// send the HTTP PUT request
client.print(F("GET /ws/rest/busarrivalservice?serviceKey="));
client.print(APIKEY);
client.print(F("&routeId="));
client.print(ROUTEID);
client.print(F("&stationId="));
client.print(STATIONID);
client.print(F(" HTTP/1.1\r\n"));
client.print(F("Host: openapi.gbis.go.kr\r\n"));
client.print(F("Connection: close\r\n"));
client.print(F("\r\n\r\n"));
}
else {
// if you couldn't make a connection
Serial.println("Connection failed");
}
}
void printWifiStatus() {
// print the SSID of the network you're attached to
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength
long rssi = WiFi.RSSI();
Serial.print("Signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
void dataParser(char c, String &data, boolean &b) {
if (c != '<') {
if (c != '>')
data += c;
}
else {
b = false;
}
}
|