|
|
本帖最后由 fischer.lunang 于 2015-1-16 11:39 编辑
为什么我的NOKIA 5110,初始化W5100后,程序运行正常,但是,5110就不显示了。但是如果取消了W5100初始化就能显示。
部分代码:
#include <EEPROM.h>
#include <pt.h>//ProtoThreads必须包含的头文件
#include <SPI.h> // 加载SPI
#include <Ethernet.h> //加载网络库
#include <EthernetUdp.h> // 加载UDP
#include <Max6675.h>
#include <nokia5110.h>
int relay1 = 2;
int relay2 = 3;
int relay3 = 4;
int relay4 = 5;
int input;
float temp_c;
float temp_f;
Max6675 ts(6, 7, 8); //依次定义SO、CS、CSK所连接的引脚号
//背景LED接的引脚
//static const int BKPIN = 1;
/*
接线方式:
时钟:SCK/CLK 接 pin9
片选:DC 接 pin11
数据输入:Din 接 pin10
复位:RST 接 pin13
使能:SCE/CE 接 pin12
*/
//声明实例对象
nokia5110 lcd(9, 10, 11, 12, 13);
EthernetClient client;
byte mac[] = { 0xB8, 0x27, 0xEB, 0xFE, 0xB2, 0x49 };
IPAddress ip(192, 168, 0, 99);
EthernetServer server(8080);
void setup() {
Ethernet.begin(mac, ip);
server.begin();//注释了这句和上一句后,5110就正常显示了。
pinMode(relay1, OUTPUT); //设定数字接口2为输入接口,控制继电器IN1
pinMode(relay2, OUTPUT); //设定数字接口3为输入接口,控制继电器IN2
pinMode(relay3, OUTPUT); //设定数字接口4为输入接口,控制继电器IN3
pinMode(relay4, OUTPUT); //设定数字接口5为输入接口,控制继电器IN4
Serial.begin(9600);//设置串口波特率为9600kbps..
lcd.begin(84, 48, 0xC8);
ts.setOffset(0);
RelayState();
}
void loop() {
input = Serial.read();
temp_c = ts.getCelsius(); //温度读取℃
temp_f = ts.getFahrenheit(); //温度读取℉
controlRelay(input);
getTemp();
delay(400);
}
void getTemp() {
Serial.print(temp_f);
Serial.print("F ");
Serial.print(temp_c);
Serial.println("'C");
lcd.setCursor(0, 0);
lcd.print("TEMP:");
lcd.setCursor(32, 0);
lcd.print(temp_c);
lcd.setCursor(74, 0);
lcd.print("C");
} |
|