need help replacing delay with millis
ok, want replace 2 spots used delay in,
i got working great need run code without delay, can help?
please
i got working great need run code without delay, can help?
please
code: [select]
#include <adafruit_gfx.h>
#include <mcufriend_kbv.h>
mcufriend_kbv tft;
#include <onewire.h>
#include <utftglue.h>
#include <dallastemperature.h>
onewire bus(31); // set pin tempurature sensor wire
dallastemperature sensors(&bus);
/// temperature
//floats
//c
float mytemp0;
float mytemp1;
float mytemp2;
float mytemp3;
float mytemp4;
float mytemp5;
//f
float mytemp0f;
float mytemp1f;
float mytemp2f;
float mytemp3f;
float mytemp4f;
float mytemp5f;
// char array print screen
//c
char sensorprintout0[8];
char sensorprintout1[8];
char sensorprintout2[8];
char sensorprintout3[8];
char sensorprintout4[8];
char sensorprintout5[8];
//f
char sensorprintout0f[8];
char sensorprintout1f[8];
char sensorprintout2f[8];
char sensorprintout3f[8];
char sensorprintout4f[8];
char sensorprintout5f[8];
//colors, either hex or decimal
#define black 0x0000
#define blue 0x001f
#define red 0xf800
#define green 0x07e0
#define cyan 0x07ff
#define magenta 0xf81f
#define yellow 0xffe0
#define white 0xffff
//fonts
//#define font1
//#define font2
//#define font3
//#define font4
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
//// start up
tft.reset();
uint16_t id = tft.readid();
tft.begin(id);
tft.setrotation(1);
tft.fillscreen(red);
tft.settextsize(4);
tft.settextcolor(white, red);
tft.setcursor(30, 100);
tft.print("start up");
delay(4000);
tft.reset();
tft.begin(id);
tft.setrotation(0);
tft.fillscreen(black);
tft.settextsize(2); // system font 8 pixels. ht = 8*x=16 x = put in brackets,
tft.setfont();
sensors.begin();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
temp();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void temp() {
///tempurature set up
tft.settextcolor(magenta, black);
tft.setcursor(20, 20);
tft.print("tempuratures ---");
readtemp(); // read temperature.
calltemp(); // call temperature.
printtemp(); // print temperature.
delay(2000);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void readtemp() {
sensors.requesttemperatures(); // send command temperatures.
//c
mytemp0 = (sensors.gettempcbyindex(0));
mytemp1 = (sensors.gettempcbyindex(1));
mytemp2 = (sensors.gettempcbyindex(2));
mytemp3 = (sensors.gettempcbyindex(3));
mytemp4 = (sensors.gettempcbyindex(4));
mytemp5 = (sensors.gettempcbyindex(5));
//f
mytemp0f = (sensors.gettempfbyindex(0));
mytemp1f = (sensors.gettempfbyindex(1));
mytemp2f = (sensors.gettempfbyindex(2));
mytemp3f = (sensors.gettempfbyindex(3));
mytemp4f = (sensors.gettempfbyindex(4));
mytemp5f = (sensors.gettempfbyindex(5));
delay(3000);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
void calltemp() {
//c
string mytemp0 = string(sensors.gettempcbyindex(0));
mytemp0.tochararray(sensorprintout0, 8);
string mytemp1 = string(sensors.gettempcbyindex(1));
mytemp1.tochararray(sensorprintout1, 8);
string mytemp2 = string(sensors.gettempcbyindex(2));
mytemp2.tochararray(sensorprintout2, 8);
string mytemp3 = string(sensors.gettempcbyindex(3));
mytemp3.tochararray(sensorprintout3, 8);
string mytemp4 = string(sensors.gettempcbyindex(4));
mytemp4.tochararray(sensorprintout4, 8);
string mytemp5 = string(sensors.gettempcbyindex(5));
mytemp5.tochararray(sensorprintout5, 8);
//f
string mytemp0f = string(sensors.gettempfbyindex(0));
mytemp0f.tochararray(sensorprintout0f, 8);
string mytemp1f = string(sensors.gettempfbyindex(1));
mytemp1f.tochararray(sensorprintout1f, 8);
string mytemp2f = string(sensors.gettempfbyindex(2));
mytemp2f.tochararray(sensorprintout2f, 8);
string mytemp3f = string(sensors.gettempfbyindex(3));
mytemp3f.tochararray(sensorprintout3f, 8);
string mytemp4f = string(sensors.gettempfbyindex(4));
mytemp4f.tochararray(sensorprintout4f, 8);
string mytemp5f = string(sensors.gettempfbyindex(5));
mytemp5f.tochararray(sensorprintout5f, 8);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void printtemp() {
// sensor one///////////////////////////////////////////////////
if ((mytemp0 >= 25) && (mytemp0 <= 30))
{
tft.settextcolor(green, black);
}
else if (mytemp0 <= 24)
{
tft.settextcolor(blue, black);
}
else if (mytemp0 >= 31)
{
tft.settextcolor(red, black);
}
tft.setcursor(160, 80);
tft.settextsize(1);
tft.print("top");
tft.settextsize(2);
tft.setcursor(0, 100);
tft.print(sensorprintout0);
tft.print(" c ");
tft.print(sensorprintout0f);
tft.print(" f");
//sensor two///////////////////////////////////////////////////
if ((mytemp1 >= 25) && (mytemp1 <= 30))
{
tft.settextcolor(green, black);
}
else if (mytemp1 <= 24)
{
tft.settextcolor(blue, black);
}
else if (mytemp1 >= 31)
{
tft.settextcolor(red, black);
}
tft.setcursor(160, 130);
tft.settextsize(1);
tft.print("top");
tft.settextsize(2);
tft.setcursor(0, 150);
tft.print(sensorprintout1);
tft.print(" c ");
tft.print(sensorprintout1f);
tft.print(" f");
//sensor three/////////////////////////////////////////////////
if ((mytemp2 >= 25) && (mytemp2 <= 30))
{
tft.settextcolor(green, black);
}
else if (mytemp2 <= 24)
{
tft.settextcolor(blue, black);
}
else if (mytemp2 >= 31)
{
tft.settextcolor(red, black);
}
tft.setcursor(160, 180);
tft.settextsize(1);
tft.print("middle");
tft.settextsize(2);
tft.setcursor(0, 200);
tft.print(sensorprintout2);
tft.print(" c ");
tft.print(sensorprintout2f);
tft.print(" f");
//sensor four//////////////////////////////////////////////////
if ((mytemp3 >= 25) && (mytemp3 <= 30))
{
tft.settextcolor(green, black);
}
else if (mytemp3 <= 24)
{
tft.settextcolor(blue, black);
}
else if (mytemp3 >= 31)
{
tft.settextcolor(red, black);
}
tft.setcursor(160, 230);
tft.settextsize(1);
tft.print("middle");
tft.settextsize(2);
tft.settextsize(2);
tft.setcursor(0, 250);
tft.print(sensorprintout3);
tft.print(" c ");
tft.print(sensorprintout3f);
tft.print(" f");
//sensor five/////////////////////////////////////////////////
if ((mytemp4 >= 25) && (mytemp4 <= 30))
{
tft.settextcolor(green, black);
}
else if (mytemp4 <= 24)
{
tft.settextcolor(blue, black);
}
else if (mytemp4 >= 31)
{
tft.settextcolor(red, black);
}
tft.setcursor(160, 280);
tft.settextsize(1);
tft.print("bottom");
tft.settextsize(2);
tft.setcursor(0, 300);
tft.print(sensorprintout4);
tft.print(" c ");
tft.print(sensorprintout4f);
tft.print(" f");
//sensor six/////////////////////////////////////////////////////
if ((mytemp5 >= 25) && (mytemp5 <= 30))
{
tft.settextcolor(green, black);
}
else if (mytemp5 <= 24)
{
tft.settextcolor(blue, black);
}
else if (mytemp5 >= 31)
{
tft.settextcolor(red, black);
}
tft.setcursor(160, 330);
tft.settextsize(1);
tft.print("bottom");
tft.settextsize(2);
tft.setcursor(0, 350);
tft.print(sensorprintout5);
tft.print(" c ");
tft.print(sensorprintout5f);
tft.print(" f");
}
tl,dr.
needs more array
needs more array
Arduino Forum > Using Arduino > Programming Questions > need help replacing delay with millis
arduino
The 100% Pure Titanium Earrings | TITanium Arts
ReplyDeleteBuy The 100% remmington titanium Pure Titanium titanium i phone case Earrings online at Titaniumarts. We offer top quality earrings for titanium wedding band sets sale that are made from iron titanium token pure titanium. nano titanium by babyliss pro
m081f7tmtli402 realistic vibrators,dildos,horse dildo,Panty Vibrators,double dildos,real dolls,silicone sex doll,penis pumps,horse dildo i226c2iixuc071
ReplyDeletel884q8wzbec370 wholesale sex toys,sex chair,dildo,rabbit vibrators,wholesale sex toys,vibrators,G-Spot Vibrators,anal toys,dog dildo p542b1vadnt570
ReplyDelete