Help adding start stop push button to program
//i trying write if() statement around code allows push button initiate program. advice wonderful. thank you!
#include<dht.h> // including library dht
#include<liquidcrystal.h>
liquidcrystal lcd(7, 6, 5, 4, 3, 2);
#define dht_dpin 12
dht dht;
#define pwm 9
byte degree[8] =
{
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00011,
0b00011
};
void setup()
{
pinmode(ledpin, output);
lcd.begin(16, 2);
lcd.createchar(1, degree);
lcd.clear();
lcd.print(" fan speed ");
lcd.setcursor(0,1);
lcd.print(" controlling ");
delay(2000);
analogwrite(pwm, 255);
lcd.clear();
lcd.print("robotics final ");
delay(2000);
}
void loop()
{
dht.read11(dht_dpin);
int temp=dht.temperature;
lcd.setcursor(0,0);
lcd.print("temperature:");
lcd.print(temp); // printing temperature on lcd
lcd.write(1);
lcd.print("c");
lcd.setcursor(0,1);
if(temp >19)
{
analogwrite(9,0);
lcd.print("fan speed: 100% ");
delay(100);
}
else if(temp<=19)
{
analogwrite(pwm, 255);
lcd.print("fan off ");
delay(100);
}
delay(3000);
}
#include<dht.h> // including library dht
#include<liquidcrystal.h>
liquidcrystal lcd(7, 6, 5, 4, 3, 2);
#define dht_dpin 12
dht dht;
#define pwm 9
byte degree[8] =
{
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00011,
0b00011
};
void setup()
{
pinmode(ledpin, output);
lcd.begin(16, 2);
lcd.createchar(1, degree);
lcd.clear();
lcd.print(" fan speed ");
lcd.setcursor(0,1);
lcd.print(" controlling ");
delay(2000);
analogwrite(pwm, 255);
lcd.clear();
lcd.print("robotics final ");
delay(2000);
}
void loop()
{
dht.read11(dht_dpin);
int temp=dht.temperature;
lcd.setcursor(0,0);
lcd.print("temperature:");
lcd.print(temp); // printing temperature on lcd
lcd.write(1);
lcd.print("c");
lcd.setcursor(0,1);
if(temp >19)
{
analogwrite(9,0);
lcd.print("fan speed: 100% ");
delay(100);
}
else if(temp<=19)
{
analogwrite(pwm, 255);
lcd.print("fan off ");
delay(100);
}
delay(3000);
}
//i trying write if() statement around code allows push button initiate program. advice wonderful.that seems @ odds title.
if want program nothing @ start until press button can achieve code in setup()
code: [select]
while (digitalread(buttonpin) == high) { // assumes low when pressed
}
...r
Arduino Forum > Using Arduino > Programming Questions > Help adding start stop push button to program
arduino
Comments
Post a Comment