极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10527|回复: 0

求助,NOKIA 5110和W5100的问题

[复制链接]
发表于 2015-1-16 11:38:05 | 显示全部楼层 |阅读模式
本帖最后由 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");

}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-17 10:58 , Processed in 0.085003 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表