phpoc쉴드이용해서 https://kocoafab.cc//make/view/448 이걸참고로 해서 프로그래밍을 짯는대요
데이터는 불러오는대 그불러온데이터로 네오픽셀이 안켜지네요 ㅜㅜ 혹시뭐가 잘못된건지알려주실수잇나요? ㅜ
제가봐선 네오픽셀에서 데이터를 못받는거같은대 어케해야될지모르겟네요 ㅜ
#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <Phpoc.h>
#define PIN 6
#ifdef __AVR__
#include <avr/power.h>
#endif
char server_name[] = "www.kma.go.kr";
PhpocClient client;
uint8_t ret;
int temp = 0;
String weather_str="";
String wt_temp="";
String wt_wfKor="";
String wt_wfEn="";
String data_seq = "";
String wt_date="";
String wt_sky="";
int sky;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
//각 변수에 정해진 공간 할당
Serial.begin(9600);
strip.begin();
strip.show();
delay(1000);
while(!Serial)
;
Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
//Phpoc.begin();
Serial.println("Sending GET request to web server");
}
void loop() {
if(client.connect(server_name, 80))
{
//Serial.println("Connected to server");
//client.println("GET / HTTP/1.0");
//client.println();
Serial.println("Connected! Making HTTP request to www.kma.go.kr");
//Serial.println("GET /data/2.5/weather?q="+location+"&mode=xml");
client.println("GET /wid/queryDFSRSS.jsp?zone=4684033000 HTTP/1.1");
//위에 지정된 주소와 연결한다.
client.print("HOST: www.kma.go.kr\n");
//client.println("User-Agent: launchpad-wifi");
client.println("Connection: close");
client.println();
Serial.println("Weather information for ");
}
if (client.connected()) {
while (client.available()) {
//라인을 기준으로 문자열을 저장한다.
String line = client.readStringUntil('\n');
//Serial.println(line);
String tmp_str = "";
//Check publish date & time
int t_date = line.indexOf("</tm>");
if(t_date >= 0)
{
tmp_str = "<tm>";
wt_date = line.substring(line.indexOf(tmp_str)+tmp_str.length(), t_date);
}
int seq= line.indexOf("<data seq=\"");
if(seq >= 0)
{
tmp_str = "<data seq=\"";
int seq_end = line.indexOf("\">");
data_seq = line.substring(seq+tmp_str.length(), seq_end);
}
if(data_seq =="0")
{
int temp11= line.indexOf("</hour>");
if(temp11>0) {
String tmp_str="<hour>";
String wt_hour = line.substring(line.indexOf(tmp_str)+tmp_str.length(),temp11);
Serial.print("hour is ");
Serial.println(wt_hour);
}
int wfEn= line.indexOf("</wfEn>");
if(wfEn>0) {
String tmp_str="<wfEn>";
String wt_twfEn = line.substring(line.indexOf(tmp_str)+tmp_str.length(),wfEn);
Serial.print("weather is ");
Serial.println(wt_twfEn);
}
int sky= line.indexOf("</sky>");
if(sky>0) {
String tmp_str="<sky>";
String wt_sky = line.substring(line.indexOf(tmp_str)+tmp_str.length(),sky);
Serial.print(" ");
Serial.println(wt_sky);
}
}
}
}
}
void weatherpixel(){
float rantime = random(20,50);
//구름
if(sky>1 && sky<4){
type3();
}
else ;
//비
if(sky>3 && sky <5){
type2();
}
else ;
//맑음
if(sky>0 && sky<2){
type1();
}
loop();
}
void type1(){
rainbow(15);
}
void type2(){
uint16_t i, j;
for(j=0; j<256; j+=1) {
for(i=0; i<strip.numPixels(); i++) {
int sum = i+j;
map(sum,0,300,120,190);
strip.setPixelColor(i, Wheel(sum),Wheel(sum),Wheel(sum));
}
strip.show();
delay(10);
}
}
void type3(){
uint16_t i, j,q;
for(q=0; q<random(1,4);q++){
for(j=0; j<256; j+=1) {
for(i=0; i<strip.numPixels(); i++) {
int sum = i+j;
map(sum,0,300,120,190);
strip.setPixelColor(i, Wheel(sum),Wheel(sum),0);
}
strip.show();
delay(10);
}
}
theaterChase(strip.Color(255, 255, 0), 60); //흰색 출력
}
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) {
for (int q=0; q < 3; q++) {
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c);
}
strip.show();
delay(wait);
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0);
}
}
}
}
uint32_t Wheel(byte WheelPos) {
if(WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
|