|
|
Elektronika.lt portalo forumas
Jūs esate neprisijungęs lankytojas. Norint dalyvauti diskusijose, būtina užsiregistruoti ir prisijungti prie forumo.
Prisijungę galėsite kurti naujas temas, atsakyti į kitų užduotus klausimus, balsuoti forumo apklausose.
Administracija pasilieka teisę pašalinti pasisakymus bei dalyvius,
kurie nesilaiko forumo taisyklių.
Pastebėjus nusižengimus, prašome pranešti.
Dabar yra 2024 10 09, 16:45. Visos datos yra GMT + 2 valandos.
|
|
|
|
Forumas » Mikrovaldikliai » Arduino platforma
|
Jūs negalite rašyti naujų pranešimų į šį forumą Jūs negalite atsakinėti į pranešimus šiame forume Jūs negalite redaguoti savo pranešimų šiame forume Jūs negalite ištrinti savo pranešimų šiame forume Jūs negalite dalyvauti apklausose šiame forume
|
|
|
|
Arduino platforma |
Parašytas: 2018 01 25, 12:15 |
|
|
|
Aciu labai uz pastebejimus, viskas susiziurejau ir puikiai vekia, aciu. |
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 05 10, 22:21 |
|
|
|
Socrates rašo: |
a1girdas rašo: |
nedera maitinti valdiklio iš to paties (stabilizatoriaus) šaltinio kaip ir relės. |
Kodel ne? Svarbu maitinimo saltinis butu pakankamai galingas visai grandinei. |
ne tame esme esme tame jei iseitu reliu iskrovimo diodai plc hajuk gali but. |
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 05 29, 15:41 |
|
|
|
Sveiki, nenorejau kurti naujos temos todel paklausiu cia. Nusipirkau tft 2.4" LCD ekrana ir negaliu rasti biblioteku, isieskojau kur tik galejau. Ekranas mcufriend firmos , testuojan ismeta tik id=4747 . Gal kas buvot susidure, padekit prasom. |
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 05 30, 11:36 |
|
|
|
Jei sei islaptines ta savo lcd, tai ir nepades tau joks krikstolinis rutulys. |
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 05 30, 13:01 |
|
|
|
MCUFRIEND_kbv padejo , ekranas pradejo rodyti informacija, bet MCUFRIEND_kbv pataisytas kazkieno ir man dar is kitos vietos pagal rekomendacijas reikejo taisyti cpp failiuka. |
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 05 30, 14:00 |
|
|
|
Ir vel vaidinsi "valstybininka" ?
Jei susitvarkei - paviesink LCD modulio nuotrauka, kad matytusi kokio gamintojo koks konkreciai variantas, kokias bibliotekas naudojai ir ka keitei, kad pradetu veikti, o ne verkti jog niekas nepadeda. |
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 05 30, 16:41 |
|
|
|
Ekranas standartinis prie arduino tft 2.4 lcd mcufriend firmos. Paleidziand testo programas , meta kad ID=0x4747 chipas nezinomas todel ir buvo problemu paleisti kad ka nors rodytu. https://www.youtube.com/watch?v=Js4wykWY6zg po siuo video yra visos nuorodos biblioteku. Bet bedos dar nesibaige, siu biblioteku ekrano valdymo sintakse kitokia negu naudojau kurdamas programele su kitokiu ekrano cipu, taigi niekas neina rekes galva dar sukti. |
|
|
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 05 31, 08:22 |
|
|
|
Va mano kodas saules kolektoriaus valdymui, dabar nepamenu koks cipas ten lcd buvo ir dabar negaliu paziureti. Nutariau padaryti kita draugui ir atsisiunciau kita LCD . Va tada bedos ir prasidejo. Siaip turiu du tokius pat lcd.
#include <OneWire.h>
#include <DallasTemperature.h>
//#include <Adafruit_GFX.h>
#include "TFTLCD.h"
#include <TouchScreen.h>
#define ONE_WIRE_BUS 10
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define YP A1
#define XM A2
#define YM 7
#define XP 6
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
#define TS_MINX 185
#define TS_MINY 161
#define TS_MAXX 953
#define TS_MAXY 885
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define MINPRESSURE 100
#define MAXPRESSURE 1000
OneWire oneWire(ONE_WIRE_BUS);
float temp, temp2, temp3, temp4, temp5, temp6 = 0;
int out_pin = 13;
int out_stat = 0;
int manual_status = 0;
int skirtum_on[] = {5, 30, 15}; //masyvas rybu nustatymo ijungimui
int skirtum_off[] = {1, 20, 5}; //masyvas rybu nustatymo isjungimui
TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
DallasTemperature sensors(&oneWire);
void setup(void){
pinMode(out_pin, OUTPUT);
digitalWrite(13, LOW);
//tft.begin(0x9341);
//tft.fillScreen(BLACK);
tft.setRotation(3);
sensors.begin();
p_ekranas ();
}
void loop(void){
//temperaturu nuskaitymas ir priskyrimas
out_stat = digitalRead(out_pin);
sensors.requestTemperatures();
temp = sensors.getTempCByIndex(0);
temp3 = sensors.getTempCByIndex(1);
temp5 = sensors.getTempCByIndex(2);
if (temp2 != temp){// boileris
tft.setTextSize(3);
tft.setCursor(208, 135);
tft.setTextColor(BLUE);
tft.println(temp2);
tft.setCursor(208, 135);
tft.setTextColor(YELLOW);
tft.println(temp);
temp2 = temp;
}
if (temp4 != temp3){//kolektorius
tft.setTextSize(2);
tft.setCursor(35, 165);
tft.setTextColor(BLACK);
tft.println(temp4);
tft.setCursor(35, 165);
tft.setTextColor(YELLOW);
tft.println(temp3);
temp4 = temp3;
}
if (temp6 != temp5){//sildymo systema
tft.setTextSize(2);
tft.setCursor(90, 90);
tft.setTextColor(BLACK);
tft.println(temp6);
tft.setCursor(90, 90);
tft.setTextColor(RED);
tft.println(temp5);
temp6 = temp5;
}
Point p = ts.getPoint();
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
p.x = map(p.x, TS_MINX, TS_MAXX, 0, 240);
p.y = map(p.y, TS_MINY, TS_MAXY, 0, 320);
//rankinis siurblio ijungimas
if (p.y > 137 && p.y < 213 && p.x > 140 && p.x < 210) {
if (out_stat == LOW){
tft.fillCircle(135, 190, 35, RED);
tft.drawCircle(135, 190, 35, RED);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.setCursor(117, 180);
tft.println("ON");
digitalWrite(out_pin, HIGH);
manual_status = 1;
}
//rankinis siurblio isjungimas
if(out_stat == HIGH){
tft.fillCircle(135, 190, 35, GREEN);
tft.drawCircle(135, 190, 35, RED);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.setCursor(110, 180);
tft.println("OFF");
digitalWrite(out_pin, LOW);
manual_status = 0;
}
}
if (p.y > 1 && p.y < 41 && p.x > 1 && p.x < 41) {//isjungimao temperaturos nuo skirtumo nustatymas
if(skirtum_off[2] < skirtum_off[1]){
tft.setTextSize(3);
tft.setCursor(232, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_off[2]);
skirtum_off[2] = skirtum_off[2]++ ;
tft.setCursor(232, 20);
tft.setTextColor(YELLOW);
tft.println(skirtum_off[2]);
}
}
if (p.y > 90 && p.y < 130 && p.x > 1 && p.x < 41) {
if(skirtum_off[2] > skirtum_off[0]){
tft.setTextSize(3);
tft.setCursor(232, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_off[2]);
skirtum_off[2] = skirtum_off[2]-- ;
tft.setTextColor(YELLOW);
tft.setCursor(232, 20);
tft.println(skirtum_off[2]);
}
}
if (p.y > 150 && p.y < 190 && p.x > 1 && p.x < 41) {//ijungimao temperaturos nuo skirtumo nustatymas
if(skirtum_on[2] < skirtum_on[1]){
tft.setTextSize(3);
tft.setCursor(80, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_on[2]);
skirtum_on[2] = skirtum_on[2]++ ;
tft.setCursor(80, 20);
tft.setTextColor(YELLOW);
tft.println(skirtum_on[2]);
}
}
if (p.y > 235 && p.y < 275 && p.x > 1 && p.x < 41) {
if(skirtum_on[2] > skirtum_on[0]){
tft.setTextSize(3);
tft.setCursor(80, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_on[2]);
skirtum_on[2] = skirtum_on[2]-- ;
tft.setTextColor(YELLOW);
tft.setCursor(80, 20);
tft.println(skirtum_on[2]);
}
}
if(manual_status == 0){
tikrinimas();
// if ( ( temp3 - temp > skirtum_on[2] ) || ( temp5 - temp > skirtum_on[2] ) ) {
//skirtumas virs max todel ijungiam
// digitalWrite(out_pin, HIGH);
// } else if( ( ( temp3 - temp > skirtum_off[2] ) && ( temp3 - temp < skirtum_on[2] ) ) || ( ( temp5 - temp > skirtum_off[2] ) && ( temp5 - temp < skirtum_on[2] ) ) ){
//skirtumas virs min ir zemiau max todel nieko nedarom
// } else {
//skirtumas zemiau min todel isjungiam
// digitalWrite(out_pin, LOW);
// }
}
}
void p_ekranas (){
uint16_t width = tft.width() - 1;
uint16_t height = tft.height() - 1;
uint8_t border = 5;
tft.fillScreen(RED);
tft.fillRect(border, border, (width - border * 2), (height - border * 2), BLACK);
tft.fillRect(20, 30, 5, 180, YELLOW);
tft.fillRect(25, 190, 75, 3, RED);
tft.fillRect(25, 80, 167, 3, RED);
tft.fillRect(50, 80, 25, 40, RED);
tft.fillCircle(135, 190, 35, GREEN);
tft.drawCircle(135, 190, 35, RED);
tft.fillRoundRect(190, 60, 120, 170, 30, BLUE);
tft.drawRoundRect(190, 60, 120, 170, 30, RED);
tft.fillRect(170, 190, 22, 3, RED);
tft.fillRect(270, 10, 40, 40, GREEN);
tft.fillRect(185, 10, 40, 40, GREEN);
tft.fillRect(35, 10, 40, 40, RED);
tft.fillRect(120, 10, 40, 40, RED);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.setCursor(48, 20);
tft.println("-");
tft.setCursor(133, 20);
tft.println("+");
tft.setCursor(197, 20);
tft.println("-");
tft.setCursor(283, 20);
tft.println("+");
tft.setCursor(110, 180);
tft.println("OFF");
tft.setCursor(231, 20);
tft.setTextColor(YELLOW);
tft.println(skirtum_off[2]);
tft.setCursor(80, 20);
tft.println(skirtum_on[2]);
}
void tikrinimas (){
if ( ( temp3 - temp > skirtum_on[2] ) || ( temp5 - temp > skirtum_on[2] ) ) {
//skirtumas virs max todel ijungiam
digitalWrite(out_pin, HIGH);
} else if( ( ( temp3 - temp > skirtum_off[2] ) && ( temp3 - temp < skirtum_on[2] ) ) || ( ( temp5 - temp > skirtum_off[2] ) && ( temp5 - temp < skirtum_on[2] ) ) ){
//skirtumas virs min ir zemiau max todel nieko nedarom
} else {
//skirtumas zemiau min todel isjungiam
digitalWrite(out_pin, LOW);
}
} |
|
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 05 31, 09:45 |
|
|
|
Tiksliai nepamenu, bet prie MCUFRIEND_kbv aprasymo buvo uzsiminta, kad tai Adafruit_GFX.h isvestine, todel visos f-jos turetu tau tikti kaip yra, o uz aparatine dali konkreciai atsakancios konkretaus LCD libai tik papildas.
Kam uzkomentavai Adafruit_GFX.h ?
Ji turi buti itraukta pirmiau aparatines dalies header'io |
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 05 31, 09:49 |
|
|
|
Pasakysiu kad dabar nepamenu uzkomentavimo. O LCD sintakse tai tikrai netinka, reikes galvoti bet kolkas neradau manualo. |
|
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 06 13, 13:46 |
|
|
|
Na va , iveikiau kinieciu stebukla. Jei kam idomu idedu koda. Kontroleris skirtas sildyti vandens boileri nuo sildymo sistemos ir saules kolektoriaus. Nusistato siurbliuko ijungimas ir isjungimas nuo temperaturu skirtumo. Rankinis ijungimas isjungimas ir temperaturu indikacija. Primityvi grafika ir lieciamas ekranas.
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_GFX.h>
#include <TouchScreen_kbv.h>
#include <EEPROM.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#define ONE_WIRE_BUS 10
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define YP A1
#define XM A2
#define YM 7
#define XP 6
TouchScreen_kbv ts = TouchScreen_kbv(XP, YP, XM, YM, 300);
#define TS_MINX 185
#define TS_MINY 161
#define TS_MAXX 953
#define TS_MAXY 885
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define MINPRESSURE 300
#define MAXPRESSURE 1000
OneWire oneWire(ONE_WIRE_BUS);
float temp, temp2, temp3, temp4, temp5, temp6 = 0;
int out_pin = 13;
int out_stat = 1;
int manual_status = 1;
int skirtum_on[] = { 5, 30, int(EEPROM.read(10)) };
int skirtum_off[] = { 1, 20, int(EEPROM.read(20)) };
DallasTemperature sensors(&oneWire);
uint16_t g_identifier;
void setup(void) {
pinMode(out_pin, OUTPUT);
digitalWrite(13, LOW);
tft.reset();
sensors.begin();
g_identifier = tft.readID();
if (g_identifier == 0xFFFF) g_identifier = 0x9341;
tft.begin(g_identifier);
tft.setRotation(3);
p_ekranas ();
motor_off();
}
void loop(void){
//tikrinam ar nustatyta temperatura, jei ne - nustatom numatytaja reiksme
if(skirtum_on[2] == 255){
skirtum_on[2] = 15;
EEPROM.write(10,15);
}
//tikrinam ar nustatyta temperatura, jei ne - nustatom numatytaja reiksme
if(skirtum_off[2] == 255){
skirtum_off[2] = 5;
EEPROM.write(20,5);
}
//temperaturu nuskaitymas ir priskyrimas
out_stat = digitalRead(out_pin);
sensors.requestTemperatures();
temp = sensors.getTempCByIndex(0);
temp3 = sensors.getTempCByIndex(1);
temp5 = sensors.getTempCByIndex(2);
if (temp2 != temp){// boileris
tft.setTextSize(3);
tft.setCursor(208, 135);
tft.setTextColor(BLUE);
tft.println(temp2);
tft.setCursor(208, 135);
tft.setTextColor(YELLOW);
tft.println(temp);
temp2 = temp;
}
if (temp4 != temp3){//kolektorius
tft.setTextSize(2);
tft.setCursor(35, 125);
tft.setTextColor(BLACK);
tft.println(temp4);
tft.setCursor(35, 125);
tft.setTextColor(YELLOW);
tft.println(temp3);
temp4 = temp3;
}
if (temp6 != temp5){//sildymo systema
tft.setTextSize(2);
tft.setCursor(35, 60);
tft.setTextColor(BLACK);
tft.println(temp6);
tft.setCursor(35, 60);
tft.setTextColor(RED);
tft.println(temp5);
temp6 = temp5;
}
TSPoint_kbv p = ts.getPoint();
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
p.x = map(p.x, TS_MINX, TS_MAXX, 0, 240);
p.y = map(p.y, TS_MINY, TS_MAXY, 0, 320);
//rankinis siurblio isjungimas
if (p.y > 270 && p.y < 305 && p.x > 185 && p.x < 230) {
digitalWrite(out_pin, LOW);
motor_off();
manual_status = 0;
tft.fillRect(35, 195, 35, 35, RED);//nudazo off mygtuka raudonai
tft.setTextSize(2);
tft.setTextColor(BLACK);
tft.setCursor(36, 208);
tft.println("OFF"); //juodai paraso off
tft.fillRect(136, 196, 33, 33, BLACK);
tft.setTextColor(GREEN);
tft.setCursor(141, 208);
tft.println("ON");
tft.setTextSize(3);
tft.fillRect(86, 196, 33, 33, BLACK);
tft.setTextColor(CYAN);
tft.setCursor(95, 202);
tft.println("A");
}
//rankinis siurblio ijungimas
if (p.y > 220 && p.y < 255 && p.x > 185 && p.x < 230) {
manual_status = 1;
tft.fillRect(85, 195, 35, 35, CYAN);
tft.setTextSize(3);
tft.setCursor(95, 202);
tft.setTextColor(BLACK);
tft.println("A");
tft.fillRect(35, 195, 35, 35, RED);
tft.fillRect(36, 196, 33, 33, BLACK);
tft.fillRect(135, 195, 35, 35, GREEN);
tft.fillRect(136, 196, 33, 33, BLACK);
tft.setTextSize(2);
tft.setTextColor(RED);
tft.setCursor(36, 208);
tft.println("OFF");
tft.setTextColor(GREEN);
tft.setCursor(141, 208);
tft.println("ON");
}
if (p.y > 165 && p.y < 200 && p.x > 185 && p.x < 230) {
digitalWrite(out_pin, HIGH);
motor_on();
manual_status = 2;
tft.fillRect(135, 195, 35, 35, GREEN);
tft.setTextSize(2);
tft.setTextColor(BLACK);
tft.setCursor(141, 208);
tft.println("ON");
tft.fillRect(36, 196, 33, 33, BLACK);
tft.setTextColor(RED);
tft.setCursor(36, 208);
tft.println("OFF");
tft.fillRect(86, 196, 33, 33, BLACK);
tft.setTextSize(3);
tft.fillRect(86, 196, 33, 33, BLACK);
tft.setTextColor(CYAN);
tft.setCursor(95, 202);
tft.println("A");
}
if (p.y > 5 && p.y < 51 && p.x > 3 && p.x < 41) {//isjungimao temperaturos nuo skirtumo nustatymas
if(skirtum_off[2] < skirtum_off[1]){
tft.setTextSize(3);
tft.setCursor(232, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_off[2]);
skirtum_off[2] = skirtum_off[2]++ ;
tft.setCursor(232, 20);
tft.setTextColor(YELLOW);
tft.println(skirtum_off[2]);
EEPROM.write(20,skirtum_off[2]);
}
}
if (p.y > 100 && p.y < 140 && p.x > 3 && p.x < 41) {
if(skirtum_off[2] > skirtum_off[0]){
tft.setTextSize(3);
tft.setCursor(232, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_off[2]);
skirtum_off[2] = skirtum_off[2]-- ;
tft.setTextColor(YELLOW);
tft.setCursor(232, 20);
tft.println(skirtum_off[2]);
EEPROM.write(20,skirtum_off[2]);
}
}
if (p.y > 170 && p.y < 210 && p.x > 3 && p.x < 41) {//ijungimao temperaturos nuo skirtumo nustatymas
if(skirtum_on[2] < skirtum_on[1]){
tft.setTextSize(3);
tft.setCursor(80, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_on[2]);
skirtum_on[2] = skirtum_on[2]++ ;
tft.setCursor(80, 20);
tft.setTextColor(YELLOW);
tft.println(skirtum_on[2]);
EEPROM.write(10,skirtum_on[2]);
}
}
if (p.y > 265 && p.y < 305 && p.x > 3 && p.x < 41) {
if(skirtum_on[2] > skirtum_on[0]){
tft.setTextSize(3);
tft.setCursor(80, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_on[2]);
skirtum_on[2] = skirtum_on[2]-- ;
tft.setTextColor(YELLOW);
tft.setCursor(80, 20);
tft.println(skirtum_on[2]);
EEPROM.write(10,skirtum_on[2]);
}
}
if(manual_status == 1){
tikrinimas();
}
}
void p_ekranas (){
uint16_t width = tft.width() - 1;
uint16_t height = tft.height() - 1;
uint8_t border = 5;
tft.fillScreen(RED);
tft.fillRect(border, border, (width - border * 2), (height - border * 2), BLACK);
tft.fillRect(20, 30, 5, 180, YELLOW);
tft.fillRect(25, 150, 75, 3, RED);
tft.fillRect(25, 80, 167, 3, RED);
tft.fillRect(50, 80, 25, 30, RED);
tft.fillRoundRect(190, 60, 120, 170, 30, BLUE);//boileris
tft.drawRoundRect(190, 60, 120, 170, 30, RED);//boilerio apvedimas
tft.fillRect(170, 150, 22, 3, RED);//trumpute apatine linija nuo kolektoriaus
tft.fillRect(270, 10, 40, 40, RED);
tft.fillRect(185, 10, 40, 40, RED);
tft.fillRect(35, 10, 40, 40, GREEN);
tft.fillRect(120, 10, 40, 40, GREEN);
tft.fillRect(35, 195, 35, 35, RED);
tft.fillRect(36, 196, 33, 33, BLACK);
tft.fillRect(85, 195, 35, 35, CYAN);
tft.fillRect(135, 195, 35, 35, GREEN);
tft.fillRect(136, 196, 33, 33, BLACK);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.setCursor(48, 20);
tft.println("-");
tft.setCursor(133, 20);
tft.println("+");
tft.setCursor(197, 20);
tft.println("-");
tft.setCursor(283, 20);
tft.println("+");
tft.setCursor(95, 202);
tft.println("A");
tft.setCursor(232, 20);
tft.setTextColor(YELLOW);
tft.println(skirtum_off[2]);
tft.setCursor(80, 20);
tft.println(skirtum_on[2]);
tft.setTextSize(2);
tft.setTextColor(RED);
tft.setCursor(36, 208);
tft.println("OFF");
tft.setTextColor(GREEN);
tft.setCursor(141, 208);
tft.println("ON");
}
void tikrinimas (){
if ( ( temp3 - temp > skirtum_on[2] ) || ( temp5 - temp > skirtum_on[2] ) ) {
//skirtumas virs max todel ijungiam
digitalWrite(out_pin, HIGH);
motor_on();
} else if( ( ( temp3 - temp > skirtum_off[2] ) && ( temp3 - temp < skirtum_on[2] ) ) || ( ( temp5 - temp > skirtum_off[2] ) && ( temp5 - temp < skirtum_on[2] ) ) ){
//skirtumas virs min ir zemiau max todel nieko nedarom
} else {
//skirtumas zemiau min todel isjungiam
digitalWrite(out_pin, LOW);
motor_off();
}
}
void motor_off (){
tft.fillCircle(135, 150, 35, RED);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.setCursor(110, 140);
tft.println("OFF");
}
void motor_on (){
tft.fillCircle(135, 150, 35, GREEN);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.setCursor(115, 140);
tft.println("ON");
} |
|
|
|
|
|
|
Arduino platforma |
Parašytas: 2018 06 18, 07:45 |
|
|
|
Daliusbag rašo: |
Jei kam idomu idedu koda. |
Kodas būtų aiškiau įskaitomas, jei būtų naudojamas bbKodas [code]
Kodas: |
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Adafruit_GFX.h>
#include <TouchScreen_kbv.h>
#include <EEPROM.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
#define ONE_WIRE_BUS 10
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
#define YP A1
#define XM A2
#define YM 7
#define XP 6
TouchScreen_kbv ts = TouchScreen_kbv(XP, YP, XM, YM, 300);
#define TS_MINX 185
#define TS_MINY 161
#define TS_MAXX 953
#define TS_MAXY 885
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define MINPRESSURE 300
#define MAXPRESSURE 1000
OneWire oneWire(ONE_WIRE_BUS);
float temp, temp2, temp3, temp4, temp5, temp6 = 0;
int out_pin = 13;
int out_stat = 1;
int manual_status = 1;
int skirtum_on[] = { 5, 30, int(EEPROM.read(10)) };
int skirtum_off[] = { 1, 20, int(EEPROM.read(20)) };
DallasTemperature sensors(&oneWire);
uint16_t g_identifier;
void setup(void) {
pinMode(out_pin, OUTPUT);
digitalWrite(13, LOW);
tft.reset();
sensors.begin();
g_identifier = tft.readID();
if (g_identifier == 0xFFFF) g_identifier = 0x9341;
tft.begin(g_identifier);
tft.setRotation(3);
p_ekranas ();
motor_off();
}
void loop(void){
//tikrinam ar nustatyta temperatura, jei ne - nustatom numatytaja reiksme
if(skirtum_on[2] == 255){
skirtum_on[2] = 15;
EEPROM.write(10,15);
}
//tikrinam ar nustatyta temperatura, jei ne - nustatom numatytaja reiksme
if(skirtum_off[2] == 255){
skirtum_off[2] = 5;
EEPROM.write(20,5);
}
//temperaturu nuskaitymas ir priskyrimas
out_stat = digitalRead(out_pin);
sensors.requestTemperatures();
temp = sensors.getTempCByIndex(0);
temp3 = sensors.getTempCByIndex(1);
temp5 = sensors.getTempCByIndex(2);
if (temp2 != temp){// boileris
tft.setTextSize(3);
tft.setCursor(208, 135);
tft.setTextColor(BLUE);
tft.println(temp2);
tft.setCursor(208, 135);
tft.setTextColor(YELLOW);
tft.println(temp);
temp2 = temp;
}
if (temp4 != temp3){//kolektorius
tft.setTextSize(2);
tft.setCursor(35, 125);
tft.setTextColor(BLACK);
tft.println(temp4);
tft.setCursor(35, 125);
tft.setTextColor(YELLOW);
tft.println(temp3);
temp4 = temp3;
}
if (temp6 != temp5){//sildymo systema
tft.setTextSize(2);
tft.setCursor(35, 60);
tft.setTextColor(BLACK);
tft.println(temp6);
tft.setCursor(35, 60);
tft.setTextColor(RED);
tft.println(temp5);
temp6 = temp5;
}
TSPoint_kbv p = ts.getPoint();
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
p.x = map(p.x, TS_MINX, TS_MAXX, 0, 240);
p.y = map(p.y, TS_MINY, TS_MAXY, 0, 320);
//rankinis siurblio isjungimas
if (p.y > 270 && p.y < 305 && p.x > 185 && p.x < 230) {
digitalWrite(out_pin, LOW);
motor_off();
manual_status = 0;
tft.fillRect(35, 195, 35, 35, RED);//nudazo off mygtuka raudonai
tft.setTextSize(2);
tft.setTextColor(BLACK);
tft.setCursor(36, 208);
tft.println("OFF"); //juodai paraso off
tft.fillRect(136, 196, 33, 33, BLACK);
tft.setTextColor(GREEN);
tft.setCursor(141, 208);
tft.println("ON");
tft.setTextSize(3);
tft.fillRect(86, 196, 33, 33, BLACK);
tft.setTextColor(CYAN);
tft.setCursor(95, 202);
tft.println("A");
}
//rankinis siurblio ijungimas
if (p.y > 220 && p.y < 255 && p.x > 185 && p.x < 230) {
manual_status = 1;
tft.fillRect(85, 195, 35, 35, CYAN);
tft.setTextSize(3);
tft.setCursor(95, 202);
tft.setTextColor(BLACK);
tft.println("A");
tft.fillRect(35, 195, 35, 35, RED);
tft.fillRect(36, 196, 33, 33, BLACK);
tft.fillRect(135, 195, 35, 35, GREEN);
tft.fillRect(136, 196, 33, 33, BLACK);
tft.setTextSize(2);
tft.setTextColor(RED);
tft.setCursor(36, 208);
tft.println("OFF");
tft.setTextColor(GREEN);
tft.setCursor(141, 208);
tft.println("ON");
}
if (p.y > 165 && p.y < 200 && p.x > 185 && p.x < 230) {
digitalWrite(out_pin, HIGH);
motor_on();
manual_status = 2;
tft.fillRect(135, 195, 35, 35, GREEN);
tft.setTextSize(2);
tft.setTextColor(BLACK);
tft.setCursor(141, 208);
tft.println("ON");
tft.fillRect(36, 196, 33, 33, BLACK);
tft.setTextColor(RED);
tft.setCursor(36, 208);
tft.println("OFF");
tft.fillRect(86, 196, 33, 33, BLACK);
tft.setTextSize(3);
tft.fillRect(86, 196, 33, 33, BLACK);
tft.setTextColor(CYAN);
tft.setCursor(95, 202);
tft.println("A");
}
if (p.y > 5 && p.y < 51 && p.x > 3 && p.x < 41) {//isjungimao temperaturos nuo skirtumo nustatymas
if(skirtum_off[2] < skirtum_off[1]){
tft.setTextSize(3);
tft.setCursor(232, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_off[2]);
skirtum_off[2] = skirtum_off[2]++ ;
tft.setCursor(232, 20);
tft.setTextColor(YELLOW);
tft.println(skirtum_off[2]);
EEPROM.write(20,skirtum_off[2]);
}
}
if (p.y > 100 && p.y < 140 && p.x > 3 && p.x < 41) {
if(skirtum_off[2] > skirtum_off[0]){
tft.setTextSize(3);
tft.setCursor(232, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_off[2]);
skirtum_off[2] = skirtum_off[2]-- ;
tft.setTextColor(YELLOW);
tft.setCursor(232, 20);
tft.println(skirtum_off[2]);
EEPROM.write(20,skirtum_off[2]);
}
}
if (p.y > 170 && p.y < 210 && p.x > 3 && p.x < 41) {//ijungimao temperaturos nuo skirtumo nustatymas
if(skirtum_on[2] < skirtum_on[1]){
tft.setTextSize(3);
tft.setCursor(80, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_on[2]);
skirtum_on[2] = skirtum_on[2]++ ;
tft.setCursor(80, 20);
tft.setTextColor(YELLOW);
tft.println(skirtum_on[2]);
EEPROM.write(10,skirtum_on[2]);
}
}
if (p.y > 265 && p.y < 305 && p.x > 3 && p.x < 41) {
if(skirtum_on[2] > skirtum_on[0]){
tft.setTextSize(3);
tft.setCursor(80, 20);
tft.setTextColor(BLACK);
tft.println(skirtum_on[2]);
skirtum_on[2] = skirtum_on[2]-- ;
tft.setTextColor(YELLOW);
tft.setCursor(80, 20);
tft.println(skirtum_on[2]);
EEPROM.write(10,skirtum_on[2]);
}
}
if(manual_status == 1){
tikrinimas();
}
}
void p_ekranas (){
uint16_t width = tft.width() - 1;
uint16_t height = tft.height() - 1;
uint8_t border = 5;
tft.fillScreen(RED);
tft.fillRect(border, border, (width - border * 2), (height - border * 2), BLACK);
tft.fillRect(20, 30, 5, 180, YELLOW);
tft.fillRect(25, 150, 75, 3, RED);
tft.fillRect(25, 80, 167, 3, RED);
tft.fillRect(50, 80, 25, 30, RED);
tft.fillRoundRect(190, 60, 120, 170, 30, BLUE);//boileris
tft.drawRoundRect(190, 60, 120, 170, 30, RED);//boilerio apvedimas
tft.fillRect(170, 150, 22, 3, RED);//trumpute apatine linija nuo kolektoriaus
tft.fillRect(270, 10, 40, 40, RED);
tft.fillRect(185, 10, 40, 40, RED);
tft.fillRect(35, 10, 40, 40, GREEN);
tft.fillRect(120, 10, 40, 40, GREEN);
tft.fillRect(35, 195, 35, 35, RED);
tft.fillRect(36, 196, 33, 33, BLACK);
tft.fillRect(85, 195, 35, 35, CYAN);
tft.fillRect(135, 195, 35, 35, GREEN);
tft.fillRect(136, 196, 33, 33, BLACK);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.setCursor(48, 20);
tft.println("-");
tft.setCursor(133, 20);
tft.println("+");
tft.setCursor(197, 20);
tft.println("-");
tft.setCursor(283, 20);
tft.println("+");
tft.setCursor(95, 202);
tft.println("A");
tft.setCursor(232, 20);
tft.setTextColor(YELLOW);
tft.println(skirtum_off[2]);
tft.setCursor(80, 20);
tft.println(skirtum_on[2]);
tft.setTextSize(2);
tft.setTextColor(RED);
tft.setCursor(36, 208);
tft.println("OFF");
tft.setTextColor(GREEN);
tft.setCursor(141, 208);
tft.println("ON");
}
void tikrinimas (){
if ( ( temp3 - temp > skirtum_on[2] ) || ( temp5 - temp > skirtum_on[2] ) ) {
//skirtumas virs max todel ijungiam
digitalWrite(out_pin, HIGH);
motor_on();
} else if( ( ( temp3 - temp > skirtum_off[2] ) && ( temp3 - temp < skirtum_on[2] ) ) || ( ( temp5 - temp > skirtum_off[2] ) && ( temp5 - temp < skirtum_on[2] ) ) ){
//skirtumas virs min ir zemiau max todel nieko nedarom
} else {
//skirtumas zemiau min todel isjungiam
digitalWrite(out_pin, LOW);
motor_off();
}
}
void motor_off (){
tft.fillCircle(135, 150, 35, RED);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.setCursor(110, 140);
tft.println("OFF");
}
void motor_on (){
tft.fillCircle(135, 150, 35, GREEN);
tft.setTextSize(3);
tft.setTextColor(BLACK);
tft.setCursor(115, 140);
tft.println("ON");
} |
|
|
|
|
|
|
|
|
Google paieška forume |
|
|
Naujos temos forume |
|
|
FS25 Tractors
Farming Simulator 25 Mods,
FS25 Maps,
FS25 Trucks |
|
ETS2 Mods
ETS2 Trucks,
ETS2 Bus,
Euro Truck Simulator 2 Mods
|
|
FS22 Tractors
Farming Simulator 22 Mods,
FS22 Maps,
FS25 Mods |
|
VAT calculator
VAT number check,
What is VAT,
How much is VAT |
|
LEGO
Mänguköök,
mudelautod,
nukuvanker |
|
Thermal monocular
Thermal vision camera,
Night vision ar scope,
Night vision spotting scope |
|
FS25 Mods
FS25 Harvesters,
FS25 Tractors Mods,
FS25 Maps Mods |
|
Dantų protezavimas
All on 4 implantai,
Endodontija mikroskopu,
Dantų implantacija |
|
FS25 Mods
FS25 Maps,
FS25 Cheats,
FS25 Install Mods |
|
GTA 6 Weapons
GTA 6 Characters,
GTA 6 Map,
GTA 6 Vehicles |
|
FS25 Mods
Farming Simulator 25 Mods |
|
|
|