ARDUINO AND 16X2 LCD BASED STOP WATCH

Simple 16X2 LCD based stop watch, the project tested on multi LCD shield, circuit includes 3 switches, start, stop and reset, project works with 7-12V DC supply or USB power input, code is written for Arduino Nano.

Arduino Connections

  • Switch 1 Arduino Pin A3  RESET SWITCH
  • Switch 2 Arduino Pin D6 TIMER START SWITCH
  • Switch 3 Arduino Pin D7 TIMER STOP SWITCH

Arduino Pins LCD

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground

Arduino Pins Vs. Various options Multi-Purpose Shield

  • Switch 1 Arduino Pin A3  RESET SWITCH
  • Switch 2 Arduino Pin D6 TIMER START SWITCH
  • Switch 3 Arduino Pin D7 TIMER STOP SWITCH
  • Current Sensor ACS714 Arduino Pin A5
  • Trimmer Potentiometer Arduino Pin A0
  • LM35 Sensor Arduino Pin A4
  • Power Mosfet Arduino Pin D9
  • Relay Arduino Pin D8


ARDUINO CODE


/*Simple LCD stopwatch program with Start, Stop, Reset Switches.
Schematic and PCB layout available at www.twovolt.com Code is modification
of original code from author TechWithZan*/

//including liblary for LCD
#include <LiquidCrystal.h>

//setting up LCD INPUT pins
LiquidCrystal lcd(12,11,5,4,3,2);

//setting hours, minutes, secound and miliseconds to 0
int h=0;
int m=0;
int s=0;
int ms=0;

//defines pin for all buttons
const int start_pin = 6;
const int stop1_pin = 7;
const int reset_pin = 17;

//defines starting points (in my case 0)
int start=0;
int stop1=0;
int reset=0;

void setup()
{

lcd.begin(16 ,2); //starting LCD

//defining pins if they are INPUT or OUTPUT pins
pinMode(start_pin, INPUT);
pinMode(stop1_pin, INPUT);
pinMode(reset_pin, INPUT);
}
void loop()
{
lcd.setCursor(0,1);
lcd.print(“STOP-WATCH”);
lcd.setCursor(0,0);
lcd.print(“TIME:”);
lcd.print(h);
lcd.print(“:”);
lcd.print(m);
lcd.print(“:”);
lcd.print(s);

start = digitalRead(start_pin); //reading buton state
if(start == HIGH)
{
stopwatch(); //goes to sub program stopwatch
}

}

void stopwatch()
{
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(“STOP-WATCH”);

stop1 = digitalRead(stop1_pin); //reading buton state
if(stop1 == HIGH) //checking if button is pressed
{
stopwatch_stop(); //going to sub program
}
else
{
stopwatch(); //going to sub program
}
}

void stopwatch_stop()
{
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(“STOP-WATCH”);

start = digitalRead(start_pin); //reading buton state
if(start == HIGH)
{
stopwatch(); //going to sub program
}

reset = digitalRead(reset_pin); //reading buton state
if(reset == HIGH)
{
stopwatch_reset(); //going to sub program
loop();
}
if(reset == LOW)
{
stopwatch_stop(); //going to sub program
}
}

void stopwatch_reset()
{
lcd.clear();
lcd.setCursor(0,1);
lcd.print(“STOPWATCH”);
h=00; //seting hours to 0
m=00; //seting minutes to 0
s=00; //seting seconds to 0
return; //exiting the program and returning to the point where entered the program
}

Watch Video Of This Project

Download Code

Download PDF Schematic

Window Comparator/Voltage Sensitive Switch TLV1701

Window Comparator/Voltage Sensitive Switch TLV1701

This circuit utilizes two comparators in parallel to determine if a signal is between two reference voltages. If the signal is within the window, the output is high. If the signal level is outside of the window, the output is low. For this design, the reference voltages are generated from a single supply with voltage dividers.

This 5V single-supply window comparator utilizes a dual open-collector comparator and two trimmer potentiometer to set the  window voltage. 2X TLV1701 was used in this design due to its low power consumption and open collector output, which allows the output to be pulled up as high as 36 V.

 

 

 

 

 

 

 

Example Circuit From Texas Instruments

 

Heat Activated Cooling Fan Controller Circuit Using LM393-LM358 & LM35 Temperature Sensor

Heat activated cooling fan controller ( Thermal Activated Cooling Fan Driver Circuit) is a simple project which operates a Brush-Less fan when the temperature in a particular area goes above a set point, when temperature return normal, fan automatically turns off. The project is built using LM358 Op-amp ( Use LM393 instead for good performance) ,  and LM35 temperature Sensor. Project required 12V DC supply and can drive 12V Fan. This project is useful in application like Heat sink temperature controller, PC, heat sensitive equipment, Power supply, Audio Amplifiers, Battery chargers, Oven.

The SMD SO8 LM35 used as temperature sensor, LM358 act as comparator provides high output when temperature rise above set point, high output drive the Fan trough driver transistor. The LM35 series are precision integrated-circuit temperature devices with an output voltage linearly-proportional to the Centigrade temperature. The LM35 device has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from the output to obtain convenient Centigrade scaling. The LM35 device does not require any external calibration or trimming to provide typical accuracies of ±¼°C at room temperature. Temperature sensing range 2 to 150 centigrade. LM35 provides output of 10mV/Centigrade.

NOTE :  It is  advisable to use LM393 Comparator instead of LM358 as it will provide better results.

  • Supply 12V DC 1Amps
  • Fan 12V DC , 500mA
  • Range : 2 °C to 150 °C
  • Open Collector Output
  • It can drive PC fan
  • Onboard preset to set the Fan trigger level
  • Onboard Power LED
  • Onboard Output LED
  • Output Driver Transistor
  • Header Connector for Supply and Fan
  • PCB dimensions 59.85 mm x 12.70 mm

Watch Video of the project available here

 

 

 

 

 

 

LM35 Temperature Sensor

The LM35 series are precision integrated-circuit temperature devices with an output voltage linearly-proportional to the Centigrade temperature. The LM35 device has an advantage over linear temperature sensors calibrated in Kelvin, as the user is not required to subtract a large constant voltage from the output to obtain convenient Centigrade scaling. The LM35 device does not require any external calibration or trimming to provide typical accuracies of ±¼°C at room temperature and ±¾°C over a full −55°C to 150°C temperature range. Lower cost is assured by trimming and calibration at the wafer level. The low-output impedance, linear output, and precise inherent calibration of the LM35 device makes interfacing to readout or control circuitry especially easy. The device is used with single power supplies, or with plus and minus supplies. As the LM35 device draws only 60 µA from the supply, it has very low self-heating of less than 0.1°C in still air. The LM35 device is rated to operate over a −55°C to 150°C temperature range, while the LM35C device is rated for a −40°C to 110°C range (−10° with improved accuracy). The LM35-series devices are available packaged in hermetic TO transistor packages, while the LM35C, LM35CA, and LM35D devices are available in the plastic TO-92 transistor package. The LM35D device is available in an 8-lead surface-mount small-outline package and a plastic TO-220 package.

 

LM358 Op-Amp

These devices consist of two independent, high-gain frequency-compensated operational amplifiers designed to operate from a single supply or split supply over a wide range of voltages.

LM393 Comparator

These devices consist of two independent voltage comparators that are designed to operate from a single power supply over a wide range of voltages. Operation from dual supplies also is possible as long as the difference between the two supplies is 2 V to 36 V, and VCC is at least 1.5 V more positive than the input common-mode voltage. Current drain is independent of the supply voltage. The outputs can be connected to other open-collector outputs to achieve wired-AND relationships.

LM293A devices are characterized for operation from −25°C to +85°C. The LM393 and LM393A devices are characterized for operation from 0°C to 70°C. The LM2903, LM2903V,

1 2 3 4