Hey everyone! I am trying to help my 12 year old son with his project and I'm stumped. We've figured out how to get temperature and do a pressure sensor and get the LCD to write out things and gone through a bunch of basic things together. Here is what he wants to do and we cannot figure it out:
If temperature is over 100 Farenheit and pressure sensor is pressed he wants a countdown timer of 120 seconds (2 minutes) to start and display on his LCD counting down.
If you press a button during that 2 minutes, he wants the code to restart at the start (its a reset button).
If you don't press a button during that 2 minutes, he wants the code to change the LCD message and light up a LCD message.
So he had thought to do a while loop
While ResetButton=High then countdown
But we don't know how to do the countdown or make sure that the chip is checking the button to see if its pushed. Can someone please help us out?
Help me! I'm a single mom and I have been working all day with my son to learn how to do this thing. I am stumped and haven't programmed since college 17 years ago!
Here is what he wants to do:
If temperature is >100 Fahrenheit and If pressure sensor is pushed then start a countdown timer for 120 seconds. If a reset button is pushed before time is out, go back to the start. If it isn't pushed at the end of 120 seconds light up an LED and display message on his LCD.
We've figured out: how to write to the LCD (yay!)
how to read the temp sensor and the pressure sensor and do both of the "if" statements to get it to work.
We cannot get the countdown and button. PLEASE help! I know it is probably completely simple and we're idiots, but honestly I'm completely stumped!
Well, it seems like you have done all the hard stuff and, by the way you describe it, I think the reset button you need is the reset button on Arduino - no extra programming required. The countdown depends on the counting procedure you surely already have, hence Larry's comment.
If temperature is >100 Fahrenheit and If pressure sensor is pushed then start a countdown timer for 120 seconds. If a reset button is pushed before time is out, go back to the start. If it isn't pushed at the end of 120 seconds light up an LED and display message on his LCD.
Seems like you need to first start to learn lcd with temperature sensor. I suggest you to check this page :
Please help--I'm a single mom and not very tech savvy. We've been looking through tutorials all day. My 12 year old son is inventing a car seat to keep kids from dying in overheated cars and wants to make a working prototype. I ordered the Arduino so he could code it and we've been working all day and are truly stumped. We want to have a 2 minute window to reset the timer--if it doesn't reset he wants the LCD message to change. There is a pressure sensor and thermometer. How do we add a 2 minute countdown and display it and have it reset if a reset button is pushed??
Here is his code so far:
#include <LiquidCrystal.h>
#include <SimpleDHT.h>
//Constants:
const int sensorPin = A0; //pin A0 to read if there is pressure
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int ResetButton = 3; //reset button
byte leds = 0;
//Variables:
int value; //save analog value
int tempPin = 0;
int pinDHT11 = 2; //Measures Temperature and Humidity
volatile int buttonState = 0; // variable for reading the pushbutton status
SimpleDHT11 dht11;
void setup() {
Serial.begin(9600); //Begin serial communication
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
pinMode(ResetButton, INPUT_PULLUP); //set up the button as an input
}
void loop() {
// put your main code here, to run repeatedly:
value = analogRead(sensorPin); //Read and save analog value from Pressure Pad
if (value>30) { // If Value is >30 then baby is in the seat
// Print a message to the LCD.
lcd.clear();
lcd.print("Baby on Board");
Serial.println("Baby on Board"); //change this to LED output
/* Once the baby is in the carseat then the temperature monitoring section of the code will begin */
Serial.println("=================================");
// start working...
// read without samples.
byte temperature = 0;
byte humidity = 0;
dht11.read(pinDHT11, &temperature, &humidity, NULL);
Serial.print("Sample Temperature: ");
Serial.print((int)temperature); Serial.print(" *C, ");
delay(1000);
//if ((int)temperature>37){ //37 Celcius is 100 Farenheit, dangerous level
if ((int)temperature>20) {//Using this to make it easier to debug
Serial.println("Text Contact"); //change this to LED output
Serial.println("Count Down To Dial 911"); //change this to LED output
//this is where we need help--want to count down from 120 seconds and if it gets to 0 we want it to display a message
if(digitalRead(ResetButton) == LOW)
{
lcd.clear();
lcd.print("Text Contact");
lcd.setCursor(0,1);
lcd.print("Dial 911 in ");
lcd.print((120-(millis() / 1000));
}
}
}
}
Moderator edit: </mark> <mark>[code]</mark> <mark>
This would probably be a good time to take a break, go to the Programming Questions section of the forum, click on the second topic ("Useful Links..."), and read all six "General Design" posts. If you study those and understand them, then you will be able to solve this problem without difficulty.