hey all,
i have an arduino uno R3 with d1 robot shield keypad.
i would like the following:
on pin dig 12 i have a hall sensor.
when the hall sensor is high(or their is a magnet near the sensor)
then a stopwatch start counting. if sensor is low,
it stops counting and displays the total high time.
when the sensor is high againt it counts further.
i have made it wit the buttons (this worked) now i change the button
with digi input and the timer STARTS without a high input code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int h=0;
int m=0;
int s=0;
int ms=0;
int start=0;
//defines pin for all buttons
const int start_pin = 12;
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(0,0);
}
void loop() {
start = digitalRead(start_pin); //reading buton state
if (start==HIGH)
{
lcd.setCursor(0,0); //setting start point on lcd
lcd.print("TIME:"); //writting TIME
lcd.print(h); //writing hours
lcd.print(":");
lcd.print(m); //writing minutes
lcd.print(":");
lcd.print(s); //writing seconds
ms=ms+10;
delay(10);
if(ms==590)
{
lcd.clear(); //clears LCD
}
if(ms==590) //if state for counting up seconds
{
ms=0;
s=s+1;
}
if(s==60) //if state for counting up minutes
{
s=0;
m=m+1;
}
if(m==60) //if state for counting up hours
{
m=00;
h=h+01;
}
lcd.setCursor(0,1);
lcd.print("brandtijd");
}
else;
lcd.setCursor(0,0);
lcd.print("TIME:");
lcd.print(h);
lcd.print(":");
lcd.print(m);
lcd.print(":");
lcd.print(s);
lcd.setCursor(0,1);
lcd.print("brandtijd");
return;
}
