Sunday, 22 July 2018

Dijital Saat & DIGITAL TIMER












his project is to create a digital timer that has quick setting time selection,
 countdown timer with alarm, elapsed timer and the ability to pause and
 restart timing. It uses an Arduino Uno, Adafruit 7-segment display and a
rotary encoder to set the time. Miscellaneous components such as capacitors
 and resistors are also required and listed in the parts list below.




You set the timer by turning the rotary encoder knob until the display shows
the required time. The knob is then pressed to start the timer and it counts down
in seconds. When the timer reaches zero it stops and sounds the alarm. If the
 encoder's knob is pressed briefly while it is counting down, the timer will stop;
pressing it again will restart where it left off. If the encoder's knob is pressed
with the display at 0:00 the elapsed timer will start and count up in seconds.
To reset the timer, the encoder's knob must be pressed and held until the display
 resets to 0:00.
The possible times that can be chosen are hard-coded in the program but can
of course be changed. The intention is to emulate some microwave ovens by
 incrementing slowly at short times but increasing the interval as the overall time
setting increases. As coded, the program permits the following times: 10s, 20s,
30s, 40s, 50s, 1m, 1m15s, 1m30s, 1m45s, 2m, 2m30s, 3m, 3m30s, 4m, 4m30s,
 5m, 5m30s, 6m, 6m30s, 7m, 7m30s, 8m, 8m30s, 9m, 9m30s, 10m, 11m, 12m,
13m, 14m, 15m, 16m, 17m, 18m, 19m, 20m, 22m, 24m, 26m, 28m, 30m, 35m,
40m, 45m, 50m, 55m, 1h, 1h5m, 1h10m, 1h15m, 1h20m, 1h25m, 1h30m. If you
 extend the array of times, the program calculates the number of time values itself
as part of its setup function. If you wanted to have all the increments in seconds,
then the relevant parts of the program might benefit from being rewritten.
The hardware components should be connected as shown in the diagram that
will appear here shortly - I am just finalising it in Fritzing. None of the components
need to connected with any specific polarity. The program can be downloaded from here.




The timer uses I2C signalling to control the LCD display (4 wires) and three digital
input pins, two for the rotary encoder and one for its SPST switch. The program
uses the default I2C address of 0x70 for the LED display.





The rotary encoder comprises two pairs of contacts that can be used to determine
the direction of rotation. One pair of contacts feeds into a digital input pin that is
set up as an interrupt, so that whenever a rising edge signal is received, a function
is called that interrupts the program. The program then checks the value on the other encoder contact; if it is set HIGH then the direction is one way, if it is not set then it's
set the other. The actual direction of rotation depends upon the encoder and how you've connected it so you may wish to swap connections if increasing time is found to be anti-clockwise. I bought the rotary encoder from Amazon and it was described as a "5 pin D shaft 20 detents 360 degree rotary encoder with push button". It cost about £2 with free delivery.
When the alarm time decreases to 0:00, the alarm sounds. The alarm is reset by
pressing the knob. The circuit as shown expects an 8Ω loudspeaker and has a
resistor in series to limit the current. The loadspeaker is connected to PWM pin 9
that can be used to generate a square wave signal at a desired frequency.
The program is written to generate two frequencies of different durations
so that the alarm can be differentiated from other sounds.


DescriptionQuantity
Adafruit 7-segment display1
Rotary encoder with push button (10-20 steps/rev)1
100nF capacitor2
10K0 resistor3
470R resistor1
8Ω loadspeaker1

No comments: