Hello,
im a beginner with the arduino uno and only a amateur in general programming.
Actually i try to build a small controller for my heating-system in my house.
Target: if temperature of water in the radiators is <> 55°C move valve to left or right.
Also i would like to see the actual temp on a tft display.
Hardware: Arduino Uno; DS18B20 Temp Sensor; ST7735 1,77 Display; Motorshield HW130 (L293D drivers)
My Problems:
- (Main Problem)
When i display the Temperature on the Display the Motor does not move anymore
(I think it has something to do with all these deinitions for the motor and the disyplay) - The display looks a bit milky (Not clear white text on black background. (Photo)
Also it seems to override the new text over the old one without deleting it.
Can you help me? (Especialy with Problem 1)
Code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
#include <AFMotor.h>#define ONE_WIRE_BUS 5
AF_DCMotor motor(3);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;
unsigned long previousMillis = 0; //Variable damit Motor nur alle 5 min dreht
const long interval = 10000; //Variable damit Motor nur alle 5 min dreht (300.000 millisec)
#define TFT_CS 6
#define TFT_RST 10 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 9
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);
float p = 3.1415926;
const uint16_t Display_Color_Black = 0x0000;
const uint16_t Display_Color_Blue = 0x001F;
const uint16_t Display_Color_Red = 0xF800;
const uint16_t Display_Color_Green = 0x07E0;
const uint16_t Display_Color_Cyan = 0x07FF;
const uint16_t Display_Color_Magenta = 0xF81F;
const uint16_t Display_Color_Yellow = 0xFFE0;
const uint16_t Display_Color_White = 0xFFFF;void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//Display
tft.initR(INITR_BLACKTAB);
tft.fillScreen(ST77XX_BLACK);
}void loop() {
// put your main code here, to run repeatedly://TEMPSensor
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0);
//Serial.print(sensors.getTempCByIndex(0));
//Serial.print(sensors.getTempCByIndex(0));
Serial.print("Temp C: ");
Serial.print(tempC);
Serial.println(" °C");//Display
uint16_t Display_Text_Color = Display_Color_Black;
uint16_t Display_Backround_Color = Display_Color_Blue;
tft.setCursor(0, 0);
////tft.setTextColor(uint16_t c);
tft.setTextWrap(true);
tft.setTextSize(3);
tft.println("Temp C: ");
tft.println(tempC);
tft.println(" °C");//Motor
unsigned long currentMillis = millis(); //Variable damit Motor nur alle 5 min dreht
Serial.print(currentMillis);
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
Serial.print("Motorloop");
motor.setSpeed(255);
if (tempC <= 55) { //Drehrichtung if
motor.run(FORWARD);
delay(500);
motor.run(RELEASE);
}
else {
motor.run(BACKWARD);
delay(500);
motor.run(RELEASE);
}
}
}
Greetings Matthias