Проблема вывода показаний датчиков на дисплей
- Войдите на сайт для отправки комментариев
Пт, 12/06/2015 - 20:49
Суть. Есть Arduino UNO, дисплей MT-12864J, датчик DHT11 и BMP085. Путем подбора библиотек и версий arduino IDE выбрал: arduino 0023, библиотеки - adafruit_BMP085 и dht. При вгрузке тестового скетча
для дисплея всё в порядке.
// Example 2435
#include <ks0108.h> // library for LCD
#include "SystemFont5x7.h"
// we need this for character display, included with ks0108.h download
void setup()
{
GLCD.Init(NON_INVERTED); // load the GLCD library
GLCD.ClearScreen();
GLCD.SelectFont(System5x7);
// choose font to use (note this needs to match the #include above
}
int j = 24;
void loop()
{
GLCD.ClearScreen();
GLCD.DrawRect(0, 0, 127, 63,BLACK);
GLCD.CursorTo(1, 1);
// set cursor to top left of LCD (uses character coordinates
// not pixel coordinates
GLCD.Puts("Hello, world."); // sends strings to LCD. Does not wrap to next line!
GLCD.CursorTo(1, 2);
GLCD.Puts("I hope you are ");
GLCD.CursorTo(1, 3);
GLCD.Puts("enjoying this");
GLCD.CursorTo(1, 4);
GLCD.Puts("series of lessons. ");
GLCD.CursorTo(1, 5);
GLCD.Puts("This is from ");
GLCD.CursorTo(1, 6);
GLCD.Puts("chapter ");
GLCD.PrintNumber(j); // sends an integer to the LCD. Does not wrap to next line either
GLCD.Puts(".");
delay(3000);
GLCD.ClearScreen();
for (int xx=0; xx<21; xx++)
{
for (int yy=0; yy<8; yy++)
{
GLCD.CursorTo(xx, yy); // position the text cursor
GLCD.Puts("#");
delay(50);
}
}
delay(1000);
GLCD.ClearScreen();
}
Но при вгрузке моего скетча
// cpega
#include <ks0108.h> // library for LCD
#include "SystemFont5x7.h"
#include "DHT.h"
#include <Wire.h>
#include <Adafruit_BMP085.h>
#define DHTPIN 2 // 2 pin для датчика DHT11
#define DHTTYPE DHT11
Adafruit_BMP085 bmp;
DHT dht(DHTPIN, DHTTYPE);
long temp3 = 0, Pressure = 0, Altitude = 0;
void setup()
{
GLCD.Init(NON_INVERTED); // load the GLCD library
GLCD.ClearScreen();
GLCD.SelectFont(System5x7);
// choose font to use (note this needs to match the #include above
Wire.begin();
dht.begin();
delay(2000);
}
void loop()
{
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius
float t = dht.readTemperature();
GLCD.ClearScreen();
GLCD.DrawRect(0,0,127,63,BLACK);
GLCD.CursorTo(1,1);
GLCD.Puts("Normal");
GLCD.CursorTo(1,2);
GLCD.Puts("Temp=");
GLCD.CursorTo(10,2);
GLCD.PrintNumber(t);
GLCD.CursorTo(1,3);
GLCD.Puts("Hum=");
GLCD.CursorTo(10,3);
GLCD.PrintNumber(h);
GLCD.CursorTo(1,4);
GLCD.Puts("Pres=");
GLCD.CursorTo(10,4);
GLCD.PrintNumber(bmp.readPressure());
delay (3000); // Задержка 3 с
GLCD.ClearScreen();
}
На экран выводится какая-то ересь - 
Вопрос. Что не так и как это исправить?