Hi all,
I am quiet newbie at programming and don't know C++ or any other programming languages. although I am good at understanding what's in front of me and can use easily to my benefit.
so I have managed to whip up an Arduino program. I had it working few months ago and still is working in my Arduino by this day, although I have changed my Personal computer since last I programmed the Arduino and have the .ino file.
now I have installed Arduino IDE programmer again and I'm getting this warning message which wasn't there before.
I have no idea what is changed or what to do next.
the programme is below.
#include <OneWire.h>
#include <ST7735.h>
#include <SPI.h>
#include <DallasTemperature.h>
OneWire ds(10); // on pin 10
DallasTemperature sensor(&ds);
//const int potin = A0;
//int potValue = 0;
//int outputValue = 0;
int n = 1;
int Relay1 = 35;
int Relay2 = 37;
int Relay3 = 39;
int Relay4 = 41;
int Relay5 = 43;
int Relay6 = 45;
int Relay7 = 47;
int Relay8 = 49;
//Ultrasonic pin definition
#define trigger 12 //Ardino pin tied to trigger pin on ultrasonic sensor
#define echo 11 // Arduino pin tied to echo pin on the ultrasonic sensor.
//TFT pin definition
#define sclk 52
#define mosi 51
#define cs 53
#define dc 9
#define rst 8
//TFT colour difinition
#define BLACK 0x0000
#define RED 0x001F
#define BLUE 0xF800
#define GREEN 0x07E0
#define YELLOW 0x07FF
#define MAGENTA 0xF81F
#define CYAN 0xFFE0
#define WHITE 0xFFFF
ST7735 tft = ST7735(cs, dc, rst, mosi, sclk);
char temperature [20];
char SetP [8];
void setup() {
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);
pinMode(A0, INPUT);
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(Relay3, OUTPUT);
pinMode(Relay4, OUTPUT);
pinMode(Relay5, OUTPUT);
pinMode(Relay6, OUTPUT);
pinMode(Relay7, OUTPUT);
pinMode(Relay8, OUTPUT);
digitalWrite(Relay1, LOW);
digitalWrite(Relay2, LOW);
digitalWrite(Relay3, LOW);
digitalWrite(Relay4, LOW);
digitalWrite(Relay5, LOW);
digitalWrite(Relay6, LOW);
digitalWrite(Relay7, LOW);
digitalWrite(Relay8, LOW);
sensor.begin();
tft.initR(); // initialize a ST7735R chip
//tft.writecommand(ST7735_DISPON);
uint16_t time = millis();
time = millis() - time;
tft.fillScreen(WHITE);
tft.drawString (0, 10, "---- System Data ---- ", RED);
tft.drawString (0, 30, " Temperature: ", BLACK);
tft.drawString (115, 30, "C" , BLACK);
tft.drawString (0, 50, " SetPoint: ", BLACK);
tft.drawString (0, 70, " Heater: ", BLACK);
tft.drawString (0, 90, " Distance: ", BLACK);
tft.drawString (115, 90, "Cm", BLACK);
}
void loop() {
readtemp();
float t = sensor.getTempCByIndex(0);
int t1 = (t - (int)t) * 100;
sprintf(temperature, "%0d.%d", (int)t, t1);
float setpoint = 0.0;
float volts = 0.0;
int counts = 0;
float ratio = 0.0;
float baseTemperature = 10.0;
float temperatureRange = 20.0;
counts = analogRead (A0);
ratio = (float)counts/1023.0;
volts = 5.0*ratio;
setpoint = (ratio*temperatureRange)+baseTemperature;
dtostrf(setpoint, 6,2, SetP);
if (t < setpoint) {
digitalWrite(Relay1, HIGH);
tft.drawString (50, 70, "ON", GREEN);
delay(2);
tft.drawString (80, 70, "OFF", WHITE);
} else if (t > setpoint) {
digitalWrite(Relay1, LOW);
tft.drawString (80, 70, "OFF", RED);
delay(2);
tft.drawString (50, 70, "ON", WHITE);
}
tft.drawString (80, 30, temperature, BLACK);
delay(5000);
tft.drawString (80, 30, temperature, WHITE);
delayMicroseconds(1);
tft.drawString (60, 50, SetP, RED);
delay (5000);
tft.drawString (60, 50, SetP, WHITE);
delay (1);
// duration = (duration / 2);
// distance = duration / 29.1;
// tft.drawString (80, 70, distance, BLACK);
}
void readtemp(void) {
sensor.requestTemperatures();
}
sorry I don't know how to embed the code in here.