- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在制作一个由 arduino + 以太网屏蔽 + LED + UV 传感器组成的项目,我需要将数据(我从传感器接收到的)发送到 mysql 数据库
#include <Wire.h>
#include "Adafruit_SI1145.h"
#include <SPI.h>
#include <Ethernet.h>
//leds
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
//arduino pin usado + leds nr pins usados
#define PIN 6
#define NUMPIXELS 20
Adafruit_SI1145 uv = Adafruit_SI1145();
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
//delay leds
int delayval = 25; // delay for half a second
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Enter the IP address for Arduino, as mentioned we will use 192.168.0.16
// Be careful to use , insetead of . when you enter the address here
IPAddress ip(192,168,137,11);
IPAddress server(192,168,137,1); // IMPORTANT: If you are using XAMPP you will have to find out the IP address of your computer and put it here (it is explained in previous article). If you have a web page, enter its address (ie. "www.yourwebpage.com")
//char server[] = "localhost";
// Initialize the Ethernet server library
EthernetClient client;
void setup() {
// Serial.begin starts the serial connection between computer and Arduino
Serial.begin(9600);
pixels.begin();
//start UV sensor
if (! uv.begin()) {
Serial.println("UV desligado");
}
Serial.println ("UV ligado");
// start the Ethernet connection
Ethernet.begin(mac, ip);
}
void loop() {
if (client.connect(server,80) > 0) {
while(client.connected()) {
// get data from sensor
float UVindex = uv.readUV();
UVindex /= 100.0;
Serial.print("UV BEFORE LEDS/DB");Serial.println(UVindex);
if(UVindex==0.02){
Serial.print("UV: "); Serial.println(UVindex);
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(150,0,0)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds)
}
}
else if(UVindex == 0.01){
Serial.print("UV: "); Serial.println(UVindex);
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds)
}
}
else if(UVindex == 0.03){
Serial.print("UV: "); Serial.println(UVindex);
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(0,0,150)); // Moderately bright green color.
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds)
}
}
// Header start
Serial.println("connected");
client.print("GET /arduino_client_UV_VALUES/pap/getUV.php?");
client.print("uv=");
client.print(UVindex);
client.println(" HTTP/1.1");
client.println("Host: 192.168.137.1");
//client.println("Connection: close");
client.println();
// Header finish
delay(1000);
}
Serial.println();
} else {
Serial.println(server);
Serial.println("connection failed");
}
// Give the server some time to recieve the data and store it. I used 10 seconds here. Be advised when delaying. If u use a short delay, the server might not capture data because of Arduino transmitting new data too soon.
delay(1000);
}
这是我的代码...我的问题是连接总是失败,我不知道该怎么办。有人能帮我吗?
除了连接之外一切正常
最佳答案
尝试更改以下内容
IP地址服务器(192,168,137,1);
到
字符服务器[] = "192.168.137.1";
关于mysql - Arduino + 紫外线传感器 + 以太网 + LED + 发送数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43104204/
嘿,我 wounderd 如果有什么。我可以继续阅读以改进此代码的突击队吗?至少它现在可以工作,但需要做一些微调:) 如您所见,代码非常困惑且难以阅读。希望有人能帮忙。 提前谢谢。 int potPi
我使用 AVR 作为微 Controller ,ATMEGA8 作为处理器(在微 Controller 内部)。带有微 Controller 的电路板有 4 个 LED。我能够刻录程序并点亮 LEDS
谁能解释一下两者之间的关系 LED 像素密度, LED像素高度和宽度 , 和 分辨率在创建模拟器时方法很详细。。并在启动时再次默认值:皮肤尺寸、密度;缩放密度以实现大小? 最佳答案 像素密度:每英寸像
我有一个由大小为 64*64 的 LED 组成的阵列。每个 LED 都可以点亮各种颜色,并且可以非常快速地改变颜色。我的最终目标是:对于网络摄像头接收到的每一帧,我希望能够从帧中“提取”LED 数组,
我正在使用 Arduino Uno 软件进行编码,但遇到了问题。我试图以随机顺序打开 8 个 LED,然后立即将它们全部关闭。我的问题是 LED 会多次点亮相同的 LED,但最终不会全部点亮。这使得电
当我使用Ethernet.begin(mac,ip)时,LED灯不会打开和关闭。但是当我不使用那条线时它就可以工作。但我需要使用以太网和 UPP 模块来打开和关闭。我怎样才能? 板卡型号:以太网08T
我试图顺时针和逆时针方向点亮我的 LED 灯。我使用mpu6050作为LED的方向控制。我检查了我的 mpu6050 驱动代码,它们没问题。顺时针方向工作时效果很好,所有 LED 灯均呈红色亮起。像这
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
我是一名优秀的程序员,十分优秀!