<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Widodo Budiharto, PhD</title>
	<atom:link href="http://widodo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://widodo.com</link>
	<description>akademisi, pengusaha dan penulis</description>
	<lastBuildDate>Thu, 19 Jan 2012 06:21:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Attendance System using Fingerprint and PIC Microcontroller</title>
		<link>http://widodo.com/teknologi-informasi/attendance-system-using-fingerprint-and-pic-microcontroller/</link>
		<comments>http://widodo.com/teknologi-informasi/attendance-system-using-fingerprint-and-pic-microcontroller/#comments</comments>
		<pubDate>Sat, 22 Oct 2011 01:48:18 +0000</pubDate>
		<dc:creator>widodo</dc:creator>
				<category><![CDATA[elektronika]]></category>
		<category><![CDATA[teknologi informasi]]></category>

		<guid isPermaLink="false">http://widodo.com/?p=620</guid>
		<description><![CDATA[Description: PR29 is an open source microcontroller Do It Yourself kit. This project provides a platform to learn about UART communication with fingerprint reader and perform as attendance marking and monitoring system. PR29 uses PIC16F876A microcontroller, 2X16 characters LCD, and SN-FPR-UART fingerprint reader
Features:

Attendance System using SN-FPR-UART Fingerprint Reader
Sample GUI which written in Visual Basic 2008 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Description:</strong> PR29 is an open source microcontroller Do It Yourself kit. This project provides a platform to learn about UART communication with fingerprint reader and perform as attendance marking and monitoring system. PR29 uses PIC16F876A microcontroller, 2X16 characters LCD, and <a href="http://www.cytron.com.my/viewProduct.php?pid=JxI0DCIKChg3CzIZAiAKOx1Is9lmtivoSxBQmYXtmEg=">SN-FPR-UART</a> fingerprint reader</p>
<p><strong>Features:</strong></p>
<ul>
<li>Attendance System using <a href="http://www.cytron.com.my/viewProduct.php?pid=JxI0DCIKChg3CzIZAiAKOx1Is9lmtivoSxBQmYXtmEg=">SN-FPR-UART</a> Fingerprint Reader</li>
<li>Sample GUI which written in Visual Basic 2008 Express Edition is provided (Usage of this GUI is elaborate in PR29 Detail Description).</li>
<li>2&#215;16LCD</li>
<li>Industrial Grade PCB with proper labeling</li>
<li>ICSP socket to ease the loading program Open Source DIY kit (schematic, source code and explanation)</li>
<li>Simple, fast and reliable learning tools</li>
</ul>
<p><span id="more-620"></span></p>
<p>#include &lt;pic.h&gt;<br />
#include&lt;htc.h&gt;                //to enable access to eeprom<br />
#include &#8220;uart_io.h&#8221;        //to enable another programmed UART</p>
<p>__CONFIG ( 0&#215;3F32 );        //configuration for the  microcontroller</p>
<p>#define LEDR        RA0        //red LED (Active HIGH)<br />
#define LEDY        RA1        //yello LED (Active HIGH)</p>
<p>#define rs            RC4        //RS pin of the LCD display<br />
#define e            RC5        //E pin of the LCD display<br />
#define lcd_data    PORTB    //LCD 8-bit data port</p>
<p>#define But1        RA2        //Push button 1 (Active LOW)<br />
#define But2         RA3        //Push button 2 (Active LOW)<br />
#define But3        RA4        //Push button 3 (Active LOW)</p>
<p>#define Buzzer        RA5        //buzzer (Active HIGH)</p>
<p>#define ACK_SUCCESS        0&#215;00    //Module reply success<br />
#define ACK_FAIL        0X01    //Module reply fail<br />
#define ACK_NOUSER        0&#215;05    //Module reply no user<br />
#define ACK_USER_EXIST    0&#215;07    //Module reply user exist<br />
#define ACK_TIMEOUT        0&#215;08    //Module reply timeout<br />
#define ACK_ACCESS        0&#215;03    //Module reply access allowed</p>
<p>void send_config(unsigned char data);<br />
void delay(unsigned long data);<br />
void send_char(unsigned char data);<br />
void lcd_goto(unsigned char data);<br />
void lcd_clr(void);<br />
void send_string(const char *s)    ;<br />
void uart_send(unsigned char data);<br />
void send_cmd(unsigned char CMD, unsigned char P1, unsigned char P2, unsigned char P3);<br />
unsigned char uart_receive(void);<br />
void mode(unsigned char data);<br />
void display_status(unsigned char type, unsigned char data0, unsigned char data);<br />
void receive_reply(void);<br />
void receive_reply_nodisplay(void);<br />
void setting_repeat(void);<br />
void CheckAdmin(void);<br />
void AddNew(unsigned char data);<br />
void store_eeprom(unsigned char data,unsigned char location);<br />
unsigned char get_eeprom(unsigned char location);<br />
void view_attendance (void);<br />
void init_attendance(void);<br />
void clear_attendance(void);<br />
void upload_HT(void);        //to hyperterminal<br />
void upload_GUI(void);        //to GUI<br />
void allign(void);<br />
void ResetAdmin(void);</p>
<p>//assign global variables<br />
bit mode_enter=0;<br />
bit location_enter;<br />
bit error;<br />
bit usertype_enter=0;<br />
bit admin;<br />
bit day_enter=0;<br />
bit GUIcontrol=0;<br />
bit export_select=0;            //local variable as flag<br />
unsigned char location=1;<br />
unsigned char day_count=1,day_location;<br />
unsigned char array_resp[8];<br />
unsigned char DAY=1;<br />
unsigned char TEMP;<br />
unsigned char mode_count=1;</p>
<p>void main(void)<br />
{<br />
//set I/O ports<br />
TRISA = 0b00011100;                    //configure PORTA I/O direction<br />
TRISB = 0b00000000;                    //configure PORTB I/O direction<br />
TRISC = 0b10000000;                    //configure PORTC I/O direction</p>
<p>//setup ADC<br />
ADCON1 = 0b10000110;                //PORTA digital I/O</p>
<p>//configure LCD display<br />
send_config(0b00000001);            //clear display at lcd<br />
send_config(0b00000010);            //lcd return to home<br />
send_config(0b00000110);            //entry mode-cursor increase 1<br />
send_config(0b00001100);            //display on, cursor off and cursor blink off<br />
send_config(0b00111000);            //function set</p>
<p>Buzzer=0;<br />
LEDY=0;</p>
<p>//display startup message<br />
lcd_clr();                            //clear lcd<br />
lcd_goto(0);                        //set the lcd cursor to location 0<br />
send_string(&#8220;Cytron Tech.&#8221;);        //display &#8220;Cytron Tech.&#8221;<br />
lcd_goto(20);                        //set the lcd cursor to location 20<br />
send_string(&#8220;PR 29&#8243;);                //display &#8220;PR 29&#8243;<br />
delay(200000);                        //delay for 100000<br />
lcd_clr();                            //clear lcd</p>
<p>//setup USART<br />
SPBRG = 0&#215;40;                        //set baud rate to 19200 for 20MHz Cystal<br />
BRGH = 1;                            //baud rate high speed option<br />
TXEN = 1;                            //enable transmission<br />
CREN = 1;                            //enable reception<br />
SPEN = 1;                            //enable serial port</p>
<p>if((!But1) &amp;&amp; (!But2))                //if both SW1 and SW2 are pressed -&gt;entering reset admin mode<br />
{<br />
delay(100000);<br />
if((!But1) &amp;&amp; (!But2))            //wait for release<br />
{<br />
ResetAdmin();                //reset admin mode<br />
}<br />
}</p>
<p>//configure reader setting<br />
send_cmd(0&#215;2E,0&#215;00,0&#215;10,0&#215;00);        //configure Time out(0&#215;10 means timeout after approx. 7s)<br />
delay(10);<br />
receive_reply_nodisplay();            //get reply from UART but do not display<br />
send_cmd(0&#215;2d,0&#215;00,1,0&#215;00);            //send command to configure not allowed repeat<br />
delay(10);<br />
receive_reply_nodisplay();            //get reply from UART but do not display</p>
<p>//initialize programmed UART<br />
uart_init(1);</p>
<p>//initialize attendance<br />
init_attendance();</p>
<p>while(1)<br />
{<br />
while(usertype_enter==0)                //usertype_enter flag not set<br />
{<br />
lcd_goto(0);                        //set lcd cursor to location 0<br />
send_string(&#8220;1. Admin login  &#8220;);    //display option 1<br />
lcd_goto(20);                        //set lcd cursor to location 20<br />
send_string(&#8220;2. User login   &#8220;);    //display option 2<br />
if(!But1)                            //User select Admin<br />
{<br />
while(!But1);//(!ButA);            //wait for release<br />
CheckAdmin();                    //verify process<br />
if(error!=1)                    //if no error return<br />
{<br />
admin = 1;                        //mark user as admin<br />
usertype_enter=1;                //set usertype_enter flag and exit loop<br />
}<br />
}<br />
else if (!But2)                        //User select user<br />
{<br />
while(!But2);                    //wait for release<br />
admin = 0;                        //mark user as normal user<br />
usertype_enter=1;                //set usertype_enter flag and exit loop<br />
}<br />
}<br />
lcd_clr();</p>
<p>while(mode_enter==0 &amp;&amp; admin ==1 &amp;&amp; usertype_enter==1)    //loop if admin logging on,chosen user type and mode not selected<br />
{<br />
if((!But1))                            //check whether SW1(INCREMENT) is pressed<br />
{<br />
while((!But1));                    //wait for release<br />
if (mode_count&lt;8)                //if not reaching 8th mode<br />
mode_count++;                    //increase mode<br />
else<br />
mode_count=1;                    //reset back to 1st mode<br />
}<br />
else if((!But2))                    //check whether SW2(DECREMENT) is pressed<br />
{<br />
while((!But2));                    //wait for release<br />
if (mode_count&gt;1)                //if not reaching 1st mode<br />
mode_count&#8211;;                    //decrease mode<br />
else<br />
mode_count=8;                    //reset back to 8th mode<br />
}<br />
else if(!But3)                        //check whether SW3(CONFIRM) is pressed<br />
{<br />
while(!But3);                    //wait for release<br />
mode_enter=1;                    //set mode_enter flag indicates user has chosen a mode<br />
}<br />
lcd_goto(0);                    //set the lcd cursor to location 0<br />
send_string(&#8220;Mode= &#8220;);            //display string<br />
lcd_goto(6);                    //set the lcd cursor to location 6<br />
send_char(0&#215;30+mode_count);        //display at location 6 (0&#215;30 is ASCII code for 0)<br />
lcd_goto(7);                    //set the lcd cursor to location 7<br />
send_string(&#8220;/8&#8243;);                //display string<br />
lcd_goto(20);                    //set the lcd cursor to location 20<br />
if (mode_count==1)     send_string(&#8220;Set Day         &#8220;);        //display description for mode 1<br />
else if (mode_count==2)    send_string(&#8220;Add a New Data  &#8220;);    //display description for mode 2<br />
else if    (mode_count==3)    send_string(&#8220;Delete a Data   &#8220;);    //display description for mode 3<br />
else if (mode_count==4)    send_string(&#8220;Delete All Data &#8220;);    //display description for mode 4<br />
else if (mode_count==5) send_string(&#8220;Change Admin    &#8220;);    //display description for mode 5<br />
else if (mode_count==6) send_string(&#8220;View Attendance &#8220;);    //display description for mode 6<br />
else if (mode_count==7) send_string(&#8220;Clear Attendance&#8221;);    //display description for mode 7<br />
else if (mode_count==8) send_string(&#8220;Export          &#8220;);    //display description for mode 8<br />
}</p>
<p>while(mode_enter==0 &amp;&amp; admin ==0 &amp;&amp; usertype_enter==1)    //loop if normal user logging on,chosen user type and mode not selected<br />
{<br />
while(1)                            //keep looping<br />
{<br />
lcd_goto(0);                        //set the lcd cursor to location 0<br />
send_string(&#8220;Today is Day &#8220;);        //display string<br />
lcd_goto(13);                        //set the lcd cursor to location 13<br />
DAY=get_eeprom(0xff);                //assign value(from eeprom location 0xff) to variable<br />
send_char(0&#215;30+DAY);                //display character<br />
lcd_goto(20);                        //set the lcd cursor to location 20<br />
send_string(&#8220;Press 3 to mark &#8220;);    //display string<br />
if(!But3)                            //if SW3 is pressed<br />
{<br />
while(!But3);                    //wait for release</p>
<p>send_cmd(0&#215;0c,0&#215;00,0&#215;00,0&#215;00);        //send matching 1:N command<br />
lcd_clr();                            //clear lcd screen<br />
lcd_goto(0);                        //set the lcd cursor to location 0<br />
send_string(&#8220;Place your thumb&#8221;);    //display string<br />
lcd_goto(20);                        //set the lcd cursor to location 20<br />
send_string(&#8220;on the window&#8221;);        //display string<br />
delay(100);<br />
receive_reply();                    //get reply from UART</p>
<p>if(!error)                            //if reply returns no error<br />
{<br />
if(DAY==1)                        //check day<br />
{    day_location=0&#215;00;            //location to store day1 data<br />
store_eeprom(0&#215;2f,day_location+3+array_resp[3]);    //get which user and mark at appropriate space<br />
delay(100);<br />
}<br />
else if(DAY==2)                    //check day<br />
{    day_location=0&#215;10;            //location to store day2 data<br />
store_eeprom(0&#215;2f,day_location+3+array_resp[3]);    //get which user and mark at appropriate space<br />
delay(100);<br />
}<br />
else if(DAY==3)                    //check day<br />
{    day_location=0&#215;20;            //location to store day3 data<br />
store_eeprom(0&#215;2f,day_location+3+array_resp[3]);    //get which user and mark at appropriate space<br />
delay(100);<br />
}<br />
else if(DAY==4)                    //check day<br />
{    day_location=0&#215;30;            //location to store day4 data<br />
store_eeprom(0&#215;2f,day_location+3+array_resp[3]);    //get which user and mark at appropriate space<br />
delay(100);<br />
}<br />
else if(DAY==5)                    //check day<br />
{    day_location=0&#215;40;            //location to store day5 data<br />
store_eeprom(0&#215;2f,day_location+3+array_resp[3]);    //get which user and mark at appropriate space<br />
delay(100);<br />
}</p>
<p>}</p>
<p>}<br />
}</p>
<p>}<br />
lcd_clr();                    //clear lcd display<br />
mode(mode_count);            //function call for mode selected<br />
delay(10);</p>
<p>}</p>
<p>}<br />
//END MAIN FUNCTION//</p>
<p>//FUNCTIONS//</p>
<p>//function to configure LCD display<br />
void send_config(unsigned char data)        //send lcd configuration<br />
{<br />
rs=0;                                    //set lcd to configuration mode<br />
lcd_data=data;                            //lcd data port = data<br />
e=1;                                    //pulse e to confirm the data<br />
delay(50);<br />
e=0;<br />
delay(50);<br />
}</p>
<p>//delay function<br />
void delay(unsigned long data)            //delay function, the delay time<br />
{                                        //depends on the given value<br />
for( ;data&gt;0;data&#8211;);<br />
}</p>
<p>//function to send character to LCD display<br />
void send_char(unsigned char data)        //send lcd character<br />
{<br />
rs=1;                                //set lcd to display mode<br />
lcd_data=data;                        //lcd data port = data<br />
e=1;                                //pulse e to confirm the data<br />
delay(10);<br />
e=0;<br />
delay(10);<br />
}</p>
<p>//function to set lcd cursor to desired location<br />
void lcd_goto(unsigned char data)        //set the location of the lcd cursor<br />
{                                        //if the given value is (0-15) the<br />
if(data&lt;16)                            //cursor will be at the upper line<br />
{                                    //if the given value is (20-35) the<br />
send_config(0&#215;80+data);            //cursor will be at the lower line<br />
}                                    //location of the lcd cursor(2X16):<br />
else                                // &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
{                                    // | |00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15| |<br />
data=data-20;                    // | |20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35| |<br />
send_config(0xc0+data);            // &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
}<br />
}</p>
<p>//function to clear LCD display<br />
void lcd_clr(void)                        //clear the lcd<br />
{<br />
send_config(0&#215;01);<br />
delay(600);<br />
}</p>
<p>//function to send string to LCD display<br />
void send_string(const char *s)            //send a string to display in the lcd<br />
{<br />
unsigned char i=0;<br />
while (s &amp;&amp; *s)send_char (*s++);</p>
<p>}</p>
<p>//function to transmit data by data to target device<br />
void uart_send(unsigned char data)        //transmit data through USART<br />
{<br />
while(TXIF==0);                        //only send the new data after<br />
TXREG=data;                            //the previous data finish sent<br />
}</p>
<p>//function to send command<br />
void send_cmd(unsigned char CMD, unsigned char P1, unsigned char P2, unsigned char P3)    //send command to fingerprint module<br />
{<br />
unsigned char CHK;<br />
CHK = CMD^P1^P2^P3^0&#215;00;    //calulate CHK(XOR CMD,P1,P2,P3,0)<br />
uart_send(0xF5);            //send first byte    (fixed)<br />
uart_send(CMD);                //send CMD<br />
uart_send(P1);                //send P1<br />
uart_send(P2);                //send P2<br />
uart_send(P3);                //send P3<br />
uart_send(0&#215;00);            //send 0    (fixed)<br />
uart_send(CHK);                //send CHK<br />
uart_send(0xF5);            //send 0xF5    (fixed)<br />
}</p>
<p>//function to receive data from uart buffer<br />
unsigned char uart_receive(void)    //receive data through USART<br />
{<br />
unsigned char rec_data;<br />
while(RCIF==0);                    //wait for data<br />
rec_data=RCREG;<br />
return rec_data;                //return received data<br />
}</p>
<p>//modes operation<br />
void mode(unsigned char data)    //check which mode to proceed<br />
{</p>
<p>if (data==1)                //mode 1 set day mode<br />
{</p>
<p>while(!day_enter)            //loop while day_enter flag is not set<br />
{<br />
if(!But1)                //check whether SW1 is pressed<br />
{<br />
while(!But1);        //wait for release<br />
if (day_count&lt;5)    //if day not reaching 5<br />
day_count++;        //increase<br />
else<br />
day_count=1;        //reset back to 1<br />
}<br />
else if(!But2)            //check whether SW2 is pressed<br />
{<br />
while(!But2);        //wait for release<br />
if (day_count&gt;1)    //if mode not reaching 1<br />
day_count&#8211;;        //decrease<br />
else<br />
day_count=5;        //reset back to 5<br />
}<br />
else if(!But3)            //check whether SW3 is pressed<br />
{<br />
lcd_clr();            //clear lcd display<br />
LEDY=1;                //yellow LED ON<br />
while(!But3);        //wait for release<br />
if(day_count==1)                         //day1<br />
{    store_eeprom(day_count,0xff);    //store at location 0xff in eeprom</p>
<p>}<br />
else if (day_count==2)                     //day2<br />
{    store_eeprom(day_count,0xff);    //store at location 0xff in eeprom</p>
<p>}<br />
else if (day_count==3)                     //day3<br />
{    store_eeprom(day_count,0xff);    //store at location 0xff in eeprom</p>
<p>}<br />
else if (day_count==4)                     //day4<br />
{    store_eeprom(day_count,0xff);    //store at location 0xff in eeprom</p>
<p>}<br />
else if (day_count==5)                     //day5<br />
{    store_eeprom(day_count,0xff);    //store at location 0xff in eeprom</p>
<p>}<br />
lcd_goto(0);                            //set the lcd cursor to location 0<br />
send_string(&#8220;Day &#8220;);                    //display string<br />
lcd_goto(4);                            //set the lcd cursor to location 4<br />
send_char(0&#215;30 + day_count);            //send character<br />
lcd_goto(20);                            //set the lcd cursor to location 20<br />
send_string(&#8220;Selected&#8221;);                //send string<br />
delay(200000);<br />
LEDY=0;                                    //OFF yellow LED<br />
day_enter=1;                            //indicates day selected<br />
}<br />
lcd_goto(0);                            //set the lcd cursor to location 0<br />
send_string(&#8220;Today is Day &#8220;);            //display string<br />
lcd_goto(13);                            //set the lcd cursor to location 13<br />
send_char(0&#215;30+day_count);                //display at location 13 (0&#215;30 is ASCII code for 0)<br />
lcd_goto(14);                            //set the lcd cursor to location 14<br />
send_string(&#8220;/5&#8243;);                        //display string<br />
lcd_goto(20);                            //set the lcd cursor to location 20<br />
send_string(&#8220;Press 3 to set  &#8220;);        //display string<br />
}<br />
day_enter=0;                                //day select operation complete day_enter flag to zero again<br />
}<br />
else if (data==2)                        //mode 2 add new data mode<br />
{<br />
delay(10000);</p>
<p>while(location_enter==0)            //loop until location_enter flag is set<br />
{<br />
lcd_goto(0);                        //set the lcd cursor to location 0<br />
send_string(&#8220;Choose User     &#8220;);    //display string<br />
lcd_goto(20);                        //set the lcd cursor to location 20<br />
send_string(&#8220;User &#8220;);                //display string<br />
lcd_goto(25);                        //set the lcd cursor to location 25<br />
send_char(0&#215;30 + location);            //display character (numerical digit which started from 0&#215;30 or zero)<br />
if(!But1)                            //if SW1 is pressed<br />
{<br />
while(!But1);                //waiting for release<br />
if (location&lt;5)                //if location is not reaching 5<br />
location++;                    //increment by 1<br />
else<br />
location=1;                    //reset back to 1<br />
}<br />
else if(!But2)                        //if SW2 is pressed<br />
{<br />
while(!But2);                    //wait for release<br />
if (location&gt;1)                    //if location is not reaching 1<br />
location&#8211;;                        //decrement by 1<br />
else<br />
location=5;                        //reset back to 5<br />
}<br />
else if(!But3)                        //if SW3 is pressed<br />
{<br />
while(!But3);                //waiting for release<br />
AddNew(location);            //function call for add new fingerprint into database at desired location<br />
}<br />
}<br />
}<br />
else if (data==3)                        //mode 3 delete a data<br />
{<br />
delay(10000);</p>
<p>while(location_enter==0)            //indicates location of data has been selected<br />
{<br />
lcd_goto(0);                        //set the lcd cursor to location 0<br />
send_string(&#8220;Choose User     &#8220;);    //display string<br />
lcd_goto(20);                        //set the lcd cursor to location 20<br />
send_string(&#8220;User &#8220;);                //display string<br />
lcd_goto(25);                        //set the lcd cursor to location 25<br />
send_char(0&#215;30 + location);            //display character (numerical digit which started from 0&#215;30 or zero)<br />
if(!But1)                            //if SW1 is pressed<br />
{<br />
while(!But1);                //waiting for release<br />
if (location&lt;5)                //if location not reaching 5<br />
location++;                    //increment by 1<br />
else<br />
location=1;                    //reset back to 1<br />
}<br />
else if(!But2)                        //if SW2 is pressed<br />
{<br />
while(!But2);                    //wait for release<br />
if (location&gt;1)                    //if location not reaching 1<br />
location&#8211;;                        //decrement by 1<br />
else<br />
location=5;                        //reset back to 5<br />
}<br />
else if(!But3)                                //if SW3 is pressed<br />
{<br />
while(!But3);                        //waiting for release<br />
send_cmd(0&#215;04,0&#215;00,location,0&#215;03);    //send delete data command<br />
delay(10);<br />
receive_reply();                    //get reply from UART<br />
location_enter=1;                    //set location_enter flag to exit loop<br />
}<br />
}<br />
}<br />
else if (data==4)                        //mode 4 delete all data<br />
{<br />
send_cmd(0&#215;05,0&#215;00,location,0&#215;03);    //send command to delete all data<br />
delay(10);<br />
receive_reply();                    //get reply from UART<br />
if(error!=1)                        //if reply returns no error<br />
{</p>
<p>do{<br />
lcd_goto(0);                    //set the lcd cursor to location 0<br />
send_string(&#8220;New Admin Needed&#8221;);//display string<br />
delay(200000);<br />
lcd_goto(0);                    //set the lcd cursor to location 0<br />
send_string(&#8220;New Admin       &#8220;);//display string<br />
lcd_goto(20);                    //set the lcd cursor to location 20<br />
send_string(&#8220;Standby         &#8220;);//display string<br />
delay(200000);<br />
AddNew(0xFF);                    //add new admin fingerrprint at location 0xFF<br />
}while(error==1)    ;<br />
}</p>
<p>}</p>
<p>else if(data==5)                        //mode 5 change Admin<br />
{<br />
lcd_goto(0);                        //set the lcd cursor to location 0<br />
send_string(&#8220;Verification of &#8220;);    //display string<br />
lcd_goto(20);                        //set the lcd cursor to location 20<br />
send_string(&#8220;Formal Admin    &#8220;)    ;    //display string<br />
delay(200000);<br />
CheckAdmin();                        //verify admin function call<br />
if(error==0)                        //if returns no error<br />
{<br />
lcd_goto(0);                        //set the lcd cursor to location 0<br />
send_string(&#8220;Deleting&#8230;&#8221;);            //display string<br />
delay(50000);<br />
send_cmd(0&#215;04,0&#215;00,0xFF,0&#215;00);        //delete formal admin<br />
receive_reply();                    //receive reply<br />
do{<br />
lcd_goto(0);                    //set the lcd cursor to location 0<br />
send_string(&#8220;New Admin       &#8220;);//display string<br />
lcd_goto(20);                    //set the lcd cursor to location 20<br />
send_string(&#8220;Standby         &#8220;);//display string<br />
delay(200000);<br />
AddNew(0xFF);                    //add new admin fingerprint<br />
}while(error==1)    ;                //if returns error, repeat<br />
}<br />
}<br />
else if(data==6)                //mode 6 view attendance<br />
{<br />
view_attendance();            //call view_attendance function<br />
}<br />
else if(data==7)                    //mode 7 clear attendance<br />
{<br />
LEDY=1;                            //yellow LED ON<br />
clear_attendance();                //call clear attebdance function<br />
lcd_goto(0);                    //set the lcd cursor to location 0<br />
send_string(&#8220;Attendance      &#8220;);//display string<br />
lcd_goto(20);                    //set the lcd cursor to location 20<br />
send_string(&#8220;Cleared         &#8220;);//display string<br />
delay(200000);<br />
LEDY=0;                            //yellow LED OFF<br />
}<br />
else if(data==8)                    //mode 8 Export<br />
{</p>
<p>while(export_select==0)                //while option flag is not set<br />
{<br />
lcd_goto(0);                    //set the lcd cursor to location 0<br />
send_string(&#8220;1. Export to GUI&#8221;);//display string<br />
lcd_goto(20);                    //set the lcd cursor to location 20<br />
send_string(&#8220;2. Export to HT &#8220;);//display string<br />
if(!But1)                                //if SW1 is pressed<br />
{<br />
while(!But1);                    //wait for release<br />
lcd_clr();                        //clear lcd<br />
lcd_goto(0);                    //set the lcd cursor to location 0<br />
send_string(&#8220;Uploading&#8230;    &#8220;);//display string<br />
LEDR=1;                            //Red LED ON<br />
delay(150000);<br />
upload_GUI();                    //call upload function<br />
lcd_goto(20);                    //set the lcd cursor to location 20<br />
send_string(&#8220;Done            &#8220;);//display string<br />
delay(100000);<br />
LEDR=0;                            //red LED OFF<br />
export_select=1;                //set flag to exit loop</p>
<p>}<br />
if(!But2)                                //if SW2 is pressed<br />
{<br />
while(!But2);                    //wait for release<br />
lcd_clr();                        //clear lcd<br />
lcd_goto(0);                    //set the lcd cursor to location 0<br />
send_string(&#8220;Uploading&#8230;    &#8220;);//display string<br />
LEDR=1;                            //red LED ON<br />
delay(150000);<br />
upload_HT();                    //call upload function<br />
lcd_goto(20);                    //set the lcd cursor to location 20<br />
send_string(&#8220;Done            &#8220;);//display string<br />
delay(100000);<br />
LEDR=0;                            //red LED OFF<br />
export_select=1;                //set flag to exit loop</p>
<p>}<br />
}<br />
export_select=0;            //reset flag<br />
}<br />
mode_enter=0;                        //reset flag<br />
location_enter=0;                    //reset flag<br />
error=0;                            //reset error<br />
}</p>
<p>//function to display the status of reply<br />
void display_status(unsigned char type, unsigned char data0, unsigned char data)    //show the status of the reply<br />
{<br />
lcd_clr();            //clear lcd display<br />
switch(data)<br />
{<br />
case ACK_SUCCESS:        LEDY=1;                                //turn ON yellow LED<br />
if((type != 1) &amp;&amp; (type != 2))<br />
{    lcd_goto(20);                    //set the lcd cursor to location 0<br />
send_string(&#8220;Successful      &#8220;);//display status<br />
}<br />
else if (type ==1)                    //During adding process 1<br />
{<br />
lcd_goto(0);                    //set the lcd cursor to location 0<br />
send_string(&#8220;Scanning&#8230;     &#8220;);//display string<br />
lcd_goto(20);                    //set the lcd cursor to location 20<br />
send_string(&#8220;Verification 1/2&#8243;);//display string<br />
}<br />
else if (type ==2)                    //During add process 2<br />
{<br />
lcd_goto(0);                    //set the lcd cursor to location 0<br />
send_string(&#8220;Scanning&#8230;     &#8220;);//display string<br />
lcd_goto(20);                    //set the lcd cursor to location 20<br />
send_string(&#8220;Verification 2/2&#8243;);//display string<br />
}<br />
delay(200000);<br />
LEDY=0;                        //turn OFF yellow LED<br />
error=0;                    //no error<br />
lcd_clr();                    //clear lcd<br />
break;</p>
<p>case ACK_FAIL:            LEDR=1;                        //turn ON red LED<br />
Buzzer=1;                    //ON buzzer<br />
lcd_goto(20);                //set the lcd cursor to location 20<br />
send_string(&#8220;Failed&#8221;);        //display status<br />
delay(200000);<br />
Buzzer=0;                    //OFF buzzer<br />
LEDR=0;                        //turn OFF red LED<br />
error=1;                    //indicates error<br />
lcd_clr();                    //clear lcd display<br />
break;</p>
<p>case ACK_TIMEOUT:        LEDR=1;                        //turn ON red LED<br />
Buzzer=1;                    //On buzzer<br />
lcd_goto(20);                //set the lcd cursor to location 20<br />
send_string(&#8220;Timeout&#8221;);        //display status<br />
delay(200000);<br />
Buzzer=0;                    //OFF buzzer<br />
LEDR=0;                        //turn OFF red LED<br />
error=1;                    //indicates error<br />
lcd_clr();                    //clear lcd display<br />
break;</p>
<p>case ACK_USER_EXIST:    LEDR=1;                        //turn ON red LED<br />
Buzzer=1;                    //ON buzzer<br />
lcd_goto(20);                //set the lcd cursor to location 20<br />
send_string(&#8220;User Exist&#8221;);    //display status<br />
delay(200000);<br />
Buzzer=0;                    //OFF buzzer<br />
LEDR=0;                        //turn OFF red LED<br />
error=1;                    //indicates error<br />
lcd_clr();                    //clear lcd display<br />
break;</p>
<p>case ACK_NOUSER:        LEDR=1;                        //turn ON red LED<br />
Buzzer=1;                    //ON buzzer<br />
lcd_goto(20);                //set the lcd cursor to location 20<br />
send_string(&#8220;Access Denied&#8221;);//display status<br />
delay(200000);<br />
Buzzer=0;                    //OFF buzzer<br />
LEDR=0;                        //turn OFF red LED<br />
error=1;                    //indicates error<br />
lcd_clr();                    //clear lcd display<br />
break;</p>
<p>case ACK_ACCESS:        LEDY=1;                        //turn ON yellow LED<br />
if(data0!=0xFF)                //if not admin (admin stored at location 0xFF)<br />
{<br />
lcd_goto(0);                //set the lcd cursor to location 0<br />
send_string(&#8220;Hello User &#8220;);    //display string<br />
lcd_goto(11);                //set the lcd cursor to location 11<br />
send_char(0&#215;30 + data0);    //display character (numerical digit which started from 0&#215;30 or zero)<br />
lcd_goto(20);                //set the lcd cursor to location 20<br />
send_string(&#8220;Welcome&#8221;);        //display string<br />
error=0;                    //no error<br />
}<br />
else<br />
{<br />
lcd_goto(0);                //set the lcd cursor to location 0<br />
send_string(&#8220;Hello Admin&#8221;);    //display string<br />
}<br />
delay(200000);<br />
LEDY=0;                        //turn OFF yellow LED<br />
lcd_clr();                    //clear lcd display<br />
break;</p>
<p>default:                LEDR=1;                    //turn ON red LED<br />
LEDY=1;                    //turn ON yellow LED<br />
Buzzer=1;                //turn ON buzzer<br />
lcd_goto(20);            //set lcd cursor to location 20<br />
send_string(&#8220;Error&#8221;);    //display string<br />
delay(200000);<br />
Buzzer=0;                //turn OFF buzzer<br />
LEDR=0;                    //turn OFF red LED<br />
LEDY=0;                    //turn OFF yellow LED<br />
error=1;                //indicates error<br />
lcd_clr();                //clear lcd display<br />
break;</p>
<p>}<br />
}</p>
<p>//function to get reply from UART<br />
void receive_reply(void)<br />
{</p>
<p>unsigned char i;<br />
for(i=0;i&lt;8;i++)                                            //store the reply in the array<br />
array_resp[i]=uart_receive();                                //assign values to array<br />
display_status(array_resp[1],array_resp[3],array_resp[4]);    //retrieve the informations<br />
delay(1000);</p>
<p>}</p>
<p>//function to get reply from UART but not display the status<br />
void receive_reply_nodisplay(void)<br />
{<br />
unsigned char i;<br />
for(i=0;i&lt;8;i++)                                //store the reply in the array<br />
array_resp[i]=uart_receive();                    //assign values to array<br />
}</p>
<p>//function to verify admin<br />
void CheckAdmin(void)<br />
{<br />
send_cmd(0&#215;0b,0&#215;00,0xFF,0&#215;00);        //send command for 1:1 Matching<br />
lcd_goto(0);                        //set the lcd cursor to location 0<br />
send_string(&#8220;Place your thumb&#8221;);    //display string<br />
lcd_goto(20);                        //set the lcd cursor to location 20<br />
send_string(&#8220;on the window&#8221;);        //display string<br />
delay(100);<br />
receive_reply();                    //get reply from UART<br />
}</p>
<p>//add new fingerprint into database<br />
void AddNew(unsigned char data)<br />
{<br />
send_cmd(0&#215;01,0&#215;00,data,0&#215;03);        //send adding new fingerprint command<br />
lcd_goto(0);                        //set the lcd cursor to location 0<br />
send_string(&#8220;Place your thumb&#8221;);    //display string<br />
lcd_goto(20);                        //set the lcd cursor to location 20<br />
send_string(&#8220;on the window&#8221;);        //display string<br />
delay(5000);<br />
receive_reply();                    //get reply from UART<br />
location_enter=1;                    //indicates location of data has been selected<br />
if(!error)                            //if no error<br />
{<br />
lcd_clr();                            //clear lcd display<br />
lcd_goto(0);<br />
send_string(&#8220;Scanning&#8230;     &#8220;);<br />
lcd_goto(20);<br />
send_string(&#8220;Verification 1/2&#8243;);<br />
send_cmd(0&#215;02,0&#215;00,data,0&#215;03);        //send verifying fingerprint #1 command<br />
receive_reply();                    //get reply from UART<br />
if(!error)                        //if no error<br />
{<br />
lcd_clr();                        //clear lcd display<br />
lcd_goto(0);<br />
send_string(&#8220;Scanning&#8230;     &#8220;);<br />
lcd_goto(20);<br />
send_string(&#8220;Verification 2/2&#8243;);<br />
send_cmd(0&#215;03,0&#215;00,data,0&#215;03);    //send verifying fingerprint #2 command<br />
receive_reply();                //get reply from UART<br />
}</p>
<p>}</p>
<p>}</p>
<p>//store data into specified location in EEPROM<br />
void store_eeprom(unsigned char data,unsigned char location)<br />
{<br />
EEPROM_WRITE(location,data);        //write data<br />
while(WR)                            //wait until it finish<br />
continue;<br />
}</p>
<p>//access EEPROM to retrieve data<br />
unsigned char get_eeprom(unsigned char location)<br />
{<br />
unsigned char value;<br />
value= EEPROM_READ(location);        //read eeprom and assign the data to variable<br />
return value;                        //return data<br />
}</p>
<p>//function to display attendance<br />
void view_attendance (void)<br />
{<br />
lcd_clr();                        //clear lcd<br />
lcd_goto(0);                     //set the lcd cursor to location 0<br />
send_string(&#8220;User 1 2 3 4 5 &#8220;);    //display string<br />
lcd_goto(20);                    //set the lcd cursor to location 20<br />
unsigned char x;<br />
for(x=0; x&lt;4; x++)        //day1 0&#215;00<br />
{    TEMP=get_eeprom(x);    //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;1&#8243;<br />
send_char(TEMP);    //display characters<br />
}<br />
for(x=4; x&lt;9; x++)        //loop 5 times for 5 days<br />
{    send_char(0&#215;20);    //display &#8221; &#8221;<br />
TEMP=get_eeprom(x);    //retrieve marking<br />
send_char(TEMP);    //display marking<br />
}<br />
delay(300000);<br />
lcd_goto(20);            //set the lcd cursor to location 20<br />
for(x=16; x&lt;20; x++)    //day2 0&#215;10<br />
{    TEMP=get_eeprom(x);    //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;2&#8243;<br />
send_char(TEMP);    //display characters<br />
}<br />
for(x=20; x&lt;25; x++)    //loop 5 times for 5 days<br />
{    send_char(0&#215;20);    //display &#8221; &#8221;<br />
TEMP=get_eeprom(x);    //retrieve marking<br />
send_char(TEMP);    //display marking<br />
}<br />
delay(300000);<br />
lcd_goto(20);            //set the lcd cursor to location 20<br />
for(x=32; x&lt;36; x++)    //day3 0&#215;20<br />
{    TEMP=get_eeprom(x);    //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;3&#8243;<br />
send_char(TEMP);    //display characters<br />
}<br />
for(x=36; x&lt;41; x++)    //loop 5 times for 5 days<br />
{    send_char(0&#215;20);    //display &#8221; &#8221;<br />
TEMP=get_eeprom(x);    //retrieve marking<br />
send_char(TEMP);    //display marking<br />
}<br />
delay(300000);<br />
lcd_goto(20);            //set the lcd cursor to location 20<br />
for(x=48; x&lt;52; x++)    //day4 0&#215;30<br />
{    TEMP=get_eeprom(x);    //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;4&#8243;<br />
send_char(TEMP);    //display characters<br />
}<br />
for(x=52; x&lt;57; x++)    //loop 5 times for 5 days<br />
{    send_char(0&#215;20);    //display &#8221; &#8221;<br />
TEMP=get_eeprom(x);    //retrieve marking<br />
send_char(TEMP);    //display marking<br />
}<br />
delay(300000);<br />
lcd_goto(20);            //set the lcd cursor to location 20<br />
for(x=64; x&lt;68; x++)    //day5 0&#215;40<br />
{    TEMP=get_eeprom(x);    //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;5&#8243;<br />
send_char(TEMP);    //display characters<br />
}<br />
for(x=68; x&lt;73; x++)    //loop 5 times for 5 days<br />
{    send_char(0&#215;20);    //display &#8221; &#8221;<br />
TEMP=get_eeprom(x);    //retrieve marking<br />
send_char(TEMP);    //display marking<br />
}<br />
delay(300000);</p>
<p>}</p>
<p>//Initialize attendance list<br />
void init_attendance(void)<br />
{<br />
day_location=0&#215;00;                    //location for day1<br />
store_eeprom(&#8216;D&#8217;,day_location);        //store character<br />
store_eeprom(&#8216;A&#8217;,day_location+1);    //store character<br />
store_eeprom(&#8216;Y&#8217;,day_location+2);    //store character<br />
store_eeprom(&#8216;1&#8242;,day_location+3);    //store character</p>
<p>day_location=0&#215;10;                    //location for day2<br />
store_eeprom(&#8216;D&#8217;,day_location);        //store character<br />
store_eeprom(&#8216;A&#8217;,day_location+1);    //store character<br />
store_eeprom(&#8216;Y&#8217;,day_location+2);    //store character<br />
store_eeprom(&#8216;2&#8242;,day_location+3);    //store character</p>
<p>day_location=0&#215;20;                    //location for day3<br />
store_eeprom(&#8216;D&#8217;,day_location);        //store character<br />
store_eeprom(&#8216;A&#8217;,day_location+1);    //store character<br />
store_eeprom(&#8216;Y&#8217;,day_location+2);    //store character<br />
store_eeprom(&#8216;3&#8242;,day_location+3);    //store character</p>
<p>day_location=0&#215;30;                    //location for day4<br />
store_eeprom(&#8216;D&#8217;,day_location);        //store character<br />
store_eeprom(&#8216;A&#8217;,day_location+1);    //store character<br />
store_eeprom(&#8216;Y&#8217;,day_location+2);    //store character<br />
store_eeprom(&#8216;4&#8242;,day_location+3);    //store character</p>
<p>day_location=0&#215;40;                    //location for day5<br />
store_eeprom(&#8216;D&#8217;,day_location);        //store character<br />
store_eeprom(&#8216;A&#8217;,day_location+1);    //store character<br />
store_eeprom(&#8216;Y&#8217;,day_location+2);    //store character<br />
store_eeprom(&#8216;5&#8242;,day_location+3);    //store character</p>
<p>}<br />
//clear attendance marking and reset to default<br />
void clear_attendance(void)<br />
{<br />
day_location=0&#215;00;                    //location for day1<br />
store_eeprom(&#8216;D&#8217;,day_location);        //store character<br />
store_eeprom(&#8216;A&#8217;,day_location+1);    //store character<br />
store_eeprom(&#8216;Y&#8217;,day_location+2);    //store character<br />
store_eeprom(&#8216;1&#8242;,day_location+3);    //store character<br />
store_eeprom(0xff,day_location+4);    //reset marking<br />
store_eeprom(0xff,day_location+5);    //reset marking<br />
store_eeprom(0xff,day_location+6);    //reset marking<br />
store_eeprom(0xff,day_location+7);    //reset marking<br />
store_eeprom(0xff,day_location+8);    //reset marking<br />
day_location=0&#215;10;                    //location for day2<br />
store_eeprom(&#8216;D&#8217;,day_location);        //store character<br />
store_eeprom(&#8216;A&#8217;,day_location+1);    //store character<br />
store_eeprom(&#8216;Y&#8217;,day_location+2);    //store character<br />
store_eeprom(&#8216;2&#8242;,day_location+3);    //store character<br />
store_eeprom(0xff,day_location+4);    //reset marking<br />
store_eeprom(0xff,day_location+5);    //reset marking<br />
store_eeprom(0xff,day_location+6);    //reset marking<br />
store_eeprom(0xff,day_location+7);    //reset marking<br />
store_eeprom(0xff,day_location+8);    //reset marking<br />
day_location=0&#215;20;<br />
store_eeprom(&#8216;D&#8217;,day_location);        //store character<br />
store_eeprom(&#8216;A&#8217;,day_location+1);    //store character<br />
store_eeprom(&#8216;Y&#8217;,day_location+2);    //store character<br />
store_eeprom(&#8216;3&#8242;,day_location+3);    //store character<br />
store_eeprom(0xff,day_location+4);    //reset marking<br />
store_eeprom(0xff,day_location+5);    //reset marking<br />
store_eeprom(0xff,day_location+6);    //reset marking<br />
store_eeprom(0xff,day_location+7);    //reset marking<br />
store_eeprom(0xff,day_location+8);    //reset marking<br />
day_location=0&#215;30;<br />
store_eeprom(&#8216;D&#8217;,day_location);        //store character<br />
store_eeprom(&#8216;A&#8217;,day_location+1);    //store character<br />
store_eeprom(&#8216;Y&#8217;,day_location+2);    //store character<br />
store_eeprom(&#8216;4&#8242;,day_location+3);    //store character<br />
store_eeprom(0xff,day_location+4);    //reset marking<br />
store_eeprom(0xff,day_location+5);    //reset marking<br />
store_eeprom(0xff,day_location+6);    //reset marking<br />
store_eeprom(0xff,day_location+7);    //reset marking<br />
store_eeprom(0xff,day_location+8);    //reset marking<br />
day_location=0&#215;40;<br />
store_eeprom(&#8216;D&#8217;,day_location);        //store character<br />
store_eeprom(&#8216;A&#8217;,day_location+1);    //store character<br />
store_eeprom(&#8216;Y&#8217;,day_location+2);    //store character<br />
store_eeprom(&#8216;5&#8242;,day_location+3);    //store character<br />
store_eeprom(0xff,day_location+4);    //reset marking<br />
store_eeprom(0xff,day_location+5);    //reset marking<br />
store_eeprom(0xff,day_location+6);    //reset marking<br />
store_eeprom(0xff,day_location+7);    //reset marking<br />
store_eeprom(0xff,day_location+8);    //reset marking<br />
}</p>
<p>//function to upload attendance to Hyper Terminal<br />
void upload_HT(void)<br />
{<br />
unsigned char address;<br />
unsigned char count;<br />
unsigned char array_title[40]= {&#8220;+-+-+- Attendance List -+-+- Cytron PR29&#8243;};    //display string</p>
<p>for(count=0;count&lt;40;count++)            //loop for 40 times<br />
uart_write(2,array_title[count]);        //write to programmed uart<br />
for(count=0;count&lt;20;count++)            //loop for 20 times<br />
{    uart_write(2,&#8217;+');                    //write &#8216;+&#8217;<br />
uart_write(2,&#8217;-');                    //write &#8216;-&#8217;<br />
}<br />
for(count=0;count&lt;80;count++)            //loop for 80 times<br />
uart_write(2,&#8217; &#8216;);                        //write to programmed uart<br />
uart_write(2,&#8217;U');                        //write to programmed uart<br />
uart_write(2,&#8217;s&#8217;);                        //write to programmed uart<br />
uart_write(2,&#8217;e');                        //write to programmed uart<br />
uart_write(2,&#8217;r');                        //write to programmed uart<br />
for(count=1;count&lt;6;count++)            //loop for 5 times<br />
{<br />
uart_write(2,&#8217; &#8216;);                    //write &#8216; &#8216;<br />
uart_write(2,0&#215;30+count);            //write user id 1 to 5<br />
}<br />
allign();                                //function making allignment</p>
<p>address=0&#215;00;                            //set address for day1<br />
count=address;                            //assign value in address to count<br />
for(address;count&lt;=address+3;count++)    //DAY1 0&#215;00-&gt;0&#215;03<br />
{<br />
TEMP=get_eeprom(count);                //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;1&#8243;<br />
uart_write(2,TEMP);                    //write to programmmed uart<br />
}<br />
address=count;                            //assign value in count to address<br />
for(count;count&lt;=address+4;count++)        //loop 5 times to get marking<br />
{<br />
TEMP=get_eeprom(count);                //get marking<br />
uart_write(2,&#8217; &#8216;);                    //write to programmed uart<br />
if(TEMP==0xff)    TEMP=0&#215;30;            //if 0xff (no marking) replace with 0&#215;30( zero )<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}<br />
allign();                                //function making allignment</p>
<p>address=0&#215;10;                            //set address for day2<br />
count=address;                            //assign value in address to count<br />
for(count;count&lt;=address+3;count++)        //DAY2 0&#215;10-&gt;0&#215;13<br />
{<br />
TEMP=get_eeprom(count);                //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;2&#8243;<br />
uart_write(2,TEMP);                    //write to programmmed uart<br />
}<br />
address=count;                            //assign value in count to address<br />
for(count;count&lt;=address+4;count++)        //loop 5 times to get marking<br />
{<br />
TEMP=get_eeprom(count);                //get marking<br />
uart_write(2,&#8217; &#8216;);                    //write to programmed uart<br />
if(TEMP==0xff)    TEMP=0&#215;30;            //if 0xff (no marking) replace with 0&#215;30( zero )<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}<br />
allign();                                //function making allignment</p>
<p>address=0&#215;20;                            //set address for day3<br />
count=address;                            //assign value in address to count<br />
for(count;count&lt;=address+3;count++)        //DAY3 0&#215;20-&gt;0&#215;23<br />
{<br />
TEMP=get_eeprom(count);                //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;3&#8243;<br />
uart_write(2,TEMP);                    //write to programmmed uart<br />
}<br />
address=count;                            //assign value in count to address<br />
for(count;count&lt;=address+4;count++)        //loop 5 times to get marking<br />
{<br />
TEMP=get_eeprom(count);                //get marking<br />
uart_write(2,&#8217; &#8216;);                    //write to programmed uart<br />
if(TEMP==0xff)    TEMP=0&#215;30;            //if 0xff (no marking) replace with 0&#215;30( zero )<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}<br />
allign();                                //function making allignment</p>
<p>address=0&#215;30;                            //set address for day4<br />
count=address;                            //assign value in address to count<br />
for(count;count&lt;=address+3;count++)        //DAY4 0&#215;30-&gt;0&#215;33<br />
{<br />
TEMP=get_eeprom(count);                //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;4&#8243;<br />
uart_write(2,TEMP);                    //write to programmmed uart<br />
}<br />
address=count;                            //assign value in count to address<br />
for(count;count&lt;=address+4;count++)        //loop 5 times to get marking<br />
{<br />
TEMP=get_eeprom(count);                //get marking<br />
uart_write(2,&#8217; &#8216;);                    //write to programmed uart<br />
if(TEMP==0xff)    TEMP=0&#215;30;            //if 0xff (no marking) replace with 0&#215;30( zero )<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}<br />
allign();                                //function making allignment</p>
<p>address=0&#215;40;                            //set address for day5<br />
count=address;                            //assign value in address to count<br />
for(count;count&lt;=address+3;count++)        //DAY5 0&#215;40-&gt;0&#215;43<br />
{<br />
TEMP=get_eeprom(count);                //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;5&#8243;<br />
uart_write(2,TEMP);                    //write to programmmed uart<br />
}<br />
address=count;                            //assign value in count to address<br />
for(count;count&lt;=address+4;count++)        //loop 5 times to get marking<br />
{<br />
TEMP=get_eeprom(count);                //get marking<br />
uart_write(2,0xff);                    //write to programmed uart<br />
if(TEMP==0xff)    TEMP=0&#215;30;            //if 0xff (no marking) replace with 0&#215;30( zero )<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}<br />
allign();                                //function making allignment<br />
for(count=0;count&lt;80;count++)            //loop 80 times<br />
uart_write(2,&#8217; &#8216;);                        //to blank a line<br />
for(count=0;count&lt;40;count++)            //loop 40 times<br />
{    uart_write(2,&#8217;+');                    //write to programmed uart<br />
uart_write(2,&#8217;-');                    //write to programmed uart</p>
<p>}<br />
}</p>
<p>//function to upload attendance to GUI<br />
void upload_GUI(void)<br />
{<br />
unsigned char address;<br />
unsigned char count;</p>
<p>address=0&#215;00;                            //day1 location<br />
count=address;                            //assign value in address to count<br />
for(address;count&lt;=address+3;count++)    //DAY1 0&#215;00-&gt;0&#215;03<br />
{<br />
TEMP=get_eeprom(count);                //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;1&#8243;<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}<br />
address=count;                            //assign value in count to address<br />
for(count;count&lt;=address+4;count++)        //loop 5 times to get marking<br />
{<br />
TEMP=get_eeprom(count);                //get marking<br />
if(TEMP==0xff)    TEMP=0&#215;30;            //if 0xff (no marking) replace with 0&#215;30( zero )<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}</p>
<p>address=0&#215;10;                            //day2 location<br />
count=address;                            //assign value in address to count<br />
for(count;count&lt;=address+3;count++)        //DAY2 0&#215;10-&gt;0&#215;13<br />
{<br />
TEMP=get_eeprom(count);                //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;2&#8243;<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}<br />
address=count;                            //assign value in count to address<br />
for(count;count&lt;=address+4;count++)        //loop 5 times to get marking<br />
{<br />
TEMP=get_eeprom(count);                //get marking<br />
if(TEMP==0xff)    TEMP=0&#215;30;            //if 0xff (no marking) replace with 0&#215;30( zero )<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}</p>
<p>address=0&#215;20;                            //day3 location<br />
count=address;                            //assign value in address to count<br />
for(count;count&lt;=address+3;count++)        //DAY3 0&#215;20-&gt;0&#215;23<br />
{<br />
TEMP=get_eeprom(count);                //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;3&#8243;<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}<br />
address=count;                            //assign value in count to address<br />
for(count;count&lt;=address+4;count++)        //loop 5 times to get marking<br />
{<br />
TEMP=get_eeprom(count);                //get marking<br />
if(TEMP==0xff)    TEMP=0&#215;30;            //if 0xff (no marking) replace with 0&#215;30( zero )<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}</p>
<p>address=0&#215;30;                            //day4 location<br />
count=address;                            //assign value in address to count<br />
for(count;count&lt;=address+3;count++)        //DAY4 0&#215;30-&gt;0&#215;33<br />
{<br />
TEMP=get_eeprom(count);                //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;4&#8243;<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}<br />
address=count;                            //assign value in count to address<br />
for(count;count&lt;=address+4;count++)        //loop 5 times to get marking<br />
{<br />
TEMP=get_eeprom(count);                //get marking<br />
if(TEMP==0xff)    TEMP=0&#215;30;            //if 0xff (no marking) replace with 0&#215;30( zero )<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}</p>
<p>address=0&#215;40;                            //day5 location<br />
count=address;                            //assign value in address to count<br />
for(count;count&lt;=address+3;count++)        //DAY5 0&#215;40-&gt;0&#215;43<br />
{<br />
TEMP=get_eeprom(count);                //get &#8220;D&#8221;,&#8221;A&#8221;,&#8221;Y&#8221;,&#8221;5&#8243;<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}<br />
address=count;                            //assign value in count to address<br />
for(count;count&lt;=address+4;count++)        //loop 5 times to get marking<br />
{<br />
TEMP=get_eeprom(count);                //get marking<br />
if(TEMP==0xff)    TEMP=0&#215;30;            //if 0xff (no marking) replace with 0&#215;30( zero )<br />
uart_write(2,TEMP);                    //write to programmed uart<br />
}</p>
<p>}</p>
<p>//function to allign the text in Hyper Terminal<br />
void allign(void)<br />
{<br />
unsigned char Allign;<br />
for(Allign=0;Allign&lt;66;Allign++)        //loop<br />
uart_write(2,&#8217; &#8216;);                        //write &#8216; &#8216; to programmed uart<br />
}</p>
<p>//function to reset and re-assign admin<br />
void ResetAdmin(void)<br />
{<br />
lcd_goto(0);                            //set the lcd cursor to location 0<br />
send_string(&#8220;Resetting Admin&#8230;&#8221;);        //display string<br />
delay(200000);<br />
send_cmd(0&#215;04,0&#215;00,0xFF,0&#215;00);            //command to delete formal admin<br />
receive_reply();                        //get reply from uart<br />
lcd_goto(0);                            //set the lcd cursor to location 0<br />
send_string(&#8220;New Admin Needed&#8221;);        //display string<br />
delay(200000);<br />
do{<br />
lcd_goto(0);                        //set the lcd cursor to location 0<br />
send_string(&#8220;New Admin       &#8220;);    //display string<br />
lcd_goto(20);                        //set the lcd cursor to location 20<br />
send_string(&#8220;Standby&#8221;);                //display string<br />
delay(200000);<br />
AddNew(0xff);                        //add new admin<br />
}    while(error==1)    ;                    //repeat if new admin not added successfully<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://widodo.com/teknologi-informasi/attendance-system-using-fingerprint-and-pic-microcontroller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display Real Time Clock (RTC) on LCD</title>
		<link>http://widodo.com/teknologi-informasi/display-real-time-clock-rtc-on-lcd/</link>
		<comments>http://widodo.com/teknologi-informasi/display-real-time-clock-rtc-on-lcd/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 16:18:09 +0000</pubDate>
		<dc:creator>widodo</dc:creator>
				<category><![CDATA[elektronika]]></category>
		<category><![CDATA[teknologi informasi]]></category>

		<guid isPermaLink="false">http://widodo.com/?p=621</guid>
		<description><![CDATA[Pelajari penampilan RTC di LCD.
Description: PR12 is an open source microcontroller Do It Yourself kit. This PIC microcontroller based project uses PIC16F876A to interface with DS1307, getting real time clock (up second) and display it on 16&#215;2 LCD. It will be fun when user have the ability to modify the setting exactly same as your [...]]]></description>
			<content:encoded><![CDATA[<p>Pelajari penampilan RTC di LCD.</p>
<p><strong>Description: </strong>PR12 is an open source microcontroller Do It Yourself kit. This PIC microcontroller based project uses PIC16F876A to interface with DS1307, getting real time clock (up second) and display it on 16&#215;2 LCD. It will be fun when user have the ability to modify the setting exactly same as your watch, all DIY. It demonstrates the approach to interface with DS1307 through I2C protocol and the programming algorithm to read/write through I2C. This RTC also have back up battery to keep the time. Cytron Technologies uploaded this project with the aim to assist hobbyist and students to pick up embedded system application and development. Download the Details Description, Sample Source, Schematic and necessary material under Useful Document. Utilize your time and enjoy it!</p>
<p><strong>Features:</strong></p>
<ul>
<li>DS1307 real time chip</li>
<li>Back up battery for at least 1 year</li>
<li>Industrial Grade PCB with proper labeling</li>
<li>ICSP socket to ease the loading program</li>
<li>Open Source DIY kit (schematic, source code and explanation)</li>
<li>Simple, fast and reliable learning tools</li>
</ul>
<p><img class="alignnone" src="http://cytron.com.my/usr_images/products/screen/PR12.jpg" alt="" width="339" height="358" /></p>
<p>Harga kit ini Rp 2.500.000 lengkap dengan kode demo.</p>
<p><span id="more-621"></span></p>
<p>//=============================================================================================<br />
//    include<br />
//=============================================================================================<br />
#include &lt;pic.h&gt;<br />
#include &#8220;i2c.h&#8221;<br />
#include &#8220;i2c_rtc.h&#8221;</p>
<p>//==========================================================================================<br />
//    configuration<br />
//=========================================================================================<br />
__CONFIG ( 0&#215;3F32 );</p>
<p>//==========================================================================================<br />
//    define<br />
//==========================================================================================<br />
#define    sw0            RC0<br />
#define sw1            RC1<br />
#define sw2            RC2<br />
#define    rs            RA0<br />
#define    e            RA1<br />
#define    led_yellow    RA2<br />
#define led_white    RA3<br />
#define    lcd_data    PORTB<br />
#define    sdata        RC4            // SDA<br />
#define    tclk        RC3            // SCL</p>
<p>//===========================================================================================<br />
//    global variable<br />
//===========================================================================================<br />
unsigned char step=0;<br />
unsigned char store=0;<br />
unsigned char clksec=0;<br />
unsigned char clkmin=0;<br />
unsigned char clkhrs=0;<br />
unsigned char day=0;<br />
unsigned char date=0;<br />
unsigned char month=0;<br />
unsigned char year=0;</p>
<p>unsigned char secondh=0;<br />
unsigned char secondl=0;<br />
unsigned char minutesh=0;<br />
unsigned char minutesl=0;<br />
unsigned char hourh=0;<br />
unsigned char hourl=0;<br />
unsigned char dateh=0;<br />
unsigned char datel=0;<br />
unsigned char monthh=0;<br />
unsigned char monthl=0;<br />
unsigned char yearh=0;<br />
unsigned char yearl=0;</p>
<p>//==============================================================================================<br />
//    function prototype<br />
//==============================================================================================<br />
void delay(unsigned long data);<br />
void send_config(unsigned char data);<br />
void send_char(unsigned char data);<br />
void e_pulse(void);<br />
void lcd_goto(unsigned char data);<br />
void lcd_clr(void);<br />
void send_string(const char *s);<br />
void send_dec(unsigned long data,unsigned char num_dig);<br />
void writertc(void);<br />
void readrtc(void);            // Read RTC</p>
<p>//============================================================================================<br />
//    main function<br />
//============================================================================================<br />
void main(void)<br />
{<br />
i2c_initialize();<br />
i2c_rtc_initialize();<br />
unsigned char i;</p>
<p>ADCON1 = 0b00000110;            //set all portA as digital I/O<br />
TRISA = 0b00000000;                //set all PORTA pin as OUTPUT<br />
TRISB = 0b00000000;                //set all PORTB pin as output<br />
TRISC = 0b00011111;                //set all PORTC pin as output</p>
<p>led_white=0;                    //led white off<br />
led_yellow=0;                    //led yellow off</p>
<p>send_config(0b00000001);        //clear display at lcd<br />
send_config(0b00000010);        //Lcd Return to home<br />
send_config(0b00000110);        //entry mode-cursor increase 1<br />
send_config(0b00001100);        //diplay on, cursor off and cursor blink off<br />
send_config(0b00111000);        //function</p>
<p>readrtc();<br />
}<br />
//================================================================================================<br />
// Write to RTC function<br />
//================================================================================================</p>
<p>void writertc(void)<br />
{<br />
led_yellow=0;                                //led yellow off<br />
led_white=1;                                //led white on</p>
<p>while(sw0==0)continue;                        //waiting sw0 to depress</p>
<p>// SET HOUR ===========================================================</p>
<p>while(sw0==1)                        //infinity loop if switch0 is not pressed<br />
{<br />
if(sw1==1)                        //if switch 1 is not pressed<br />
{<br />
lcd_goto(0);            //maintain current hour value on LCD and make it blinking<br />
send_dec(clkhrs,2);<br />
delay(10000);<br />
lcd_goto(1);<br />
send_char(&#8216; &#8216;);<br />
lcd_goto(0);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
if(sw1==0)                                //if switch 1 is pressed<br />
{<br />
while(sw1==0)continue;                //wait switch1 to depress</p>
<p>if(clkhrs&lt;=22)clkhrs++;<br />
else clkhrs=0;<br />
}<br />
}</p>
<p>lcd_goto(0);                                //overwrite changed hour value on LCD<br />
send_dec(clkhrs,2);<br />
while(sw0==0)continue;                        //wait switch 0 to be depressed</p>
<p>// SET MINUTES ====================================================================</p>
<p>while(sw0==1)                                //infinity loop if switch0 is not pressed<br />
{<br />
if(sw1==1)                                //if switch 1 is not pressed<br />
{<br />
lcd_goto(3);                //maintain current minute value on LCD and make it blinking<br />
send_dec(clkmin,2);<br />
delay(10000);<br />
lcd_goto(4);<br />
send_char(&#8216; &#8216;);<br />
lcd_goto(3);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
if(sw1==0)                                //if switch 1 is pressed<br />
{<br />
while(sw1==0)continue;                //wait switch1 to depress</p>
<p>if(clkmin&lt;=58) clkmin++;<br />
else clkmin=0;<br />
}<br />
}</p>
<p>lcd_goto(3);                                //overwrite changed minute value on LCD<br />
send_dec(clkmin,2);<br />
while(sw0==0)continue;                        //wait switch 0 to be depressed</p>
<p>// SET SECONDS ===============================================================</p>
<p>while(sw0==1)                            //infinity loop if switch0 is not pressed<br />
{</p>
<p>if(sw1==1)                            //if switch 1 is not pressed<br />
{<br />
lcd_goto(6);                //maintain current minute value on LCD and make it blinking<br />
send_dec(clksec,2);<br />
delay(10000);<br />
lcd_goto(7);<br />
send_char(&#8216; &#8216;);<br />
lcd_goto(6);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
if(sw1==0)                                //if switch 1 is pressed<br />
{<br />
while(sw1==0)continue;                //wait switch1 to depress</p>
<p>if(clksec&lt;=58) clksec++;<br />
else clksec=0;<br />
}<br />
}</p>
<p>lcd_goto(6);                                //overwrite changed second value on LCD<br />
send_dec(clksec,2);<br />
while(sw0==0)continue;                        //wait switch 0 to be depressed</p>
<p>// SET DATE =========================================</p>
<p>while(sw0==1)                        //infinity loop if switch0 is not pressed<br />
{</p>
<p>if(sw1==1)                        //if switch 1 is not pressed<br />
{<br />
lcd_goto(20);                //maintain current date value on LCD and make it blinking<br />
send_dec(date,2);<br />
delay(10000);<br />
lcd_goto(21);<br />
send_char(&#8216; &#8216;);<br />
lcd_goto(20);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
if(sw1==0)                                //if switch 1 is pressed<br />
{<br />
while(sw1==0)continue;                //wait switch1 to depress</p>
<p>if(date&lt;=30) date++;<br />
else date=1;<br />
}<br />
}</p>
<p>lcd_goto(20);                                //overwrite changed date value on LCD<br />
send_dec(date,2);<br />
while(sw0==0)continue;                        //wait switch 0 to be depressed</p>
<p>// SET MONTH ==========================================</p>
<p>while(sw0==1)                        //infinity loop if switch0 is not pressed<br />
{</p>
<p>if(sw1==1)                        //if switch 1 is not pressed<br />
{<br />
lcd_goto(23);                //maintain current month value on LCD and make it blinking<br />
send_dec(month,2);<br />
delay(10000);<br />
lcd_goto(24);<br />
send_char(&#8216; &#8216;);<br />
lcd_goto(23);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
if(sw1==0)                                //if switch 1 is pressed<br />
{<br />
while(sw1==0)continue;                //wait switch1 to depress</p>
<p>if(month&lt;=11) month++;<br />
else month=1;<br />
}<br />
}</p>
<p>lcd_goto(23);                                //overwrite changed month value on LCD<br />
send_dec(month,2);<br />
while(sw0==0)continue;                        //wait switch 0 to be depressed</p>
<p>// SET YEAR =======================================================================================</p>
<p>while(sw0==1)                        //infinity loop if switch0 is not pressed<br />
{</p>
<p>if(sw1==1)                        //if switch 1 is not pressed<br />
{<br />
lcd_goto(26);                //maintain current month value on LCD and make it blinking<br />
send_dec(year,2);<br />
delay(10000);<br />
lcd_goto(27);<br />
send_char(&#8216; &#8216;);<br />
lcd_goto(26);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
if(sw1==0)                                //if switch 1 is pressed<br />
{<br />
while(sw1==0)continue;                //wait switch1 to depress</p>
<p>if(year&lt;=99) year++;<br />
else year=0;<br />
}<br />
}</p>
<p>lcd_goto(26);                            //overwrite changed year value on LCD<br />
send_dec(year,2);<br />
while(sw0==0)continue;                    //wait switch 0 to be depressed</p>
<p>// SET DAY ====================================================================================</p>
<p>while(sw0==1)                    //infinity loop if switch0 is not pressed<br />
{<br />
if(sw1==1)                    //if switch 1 is not pressed<br />
{<br />
if(day==7)                //maintain current day value on LCD and make it blinking<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;SUN&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==1)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;MON&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==2)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;TUE&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==3)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;WED&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==4)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;THU&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==5)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;FRI&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==6)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;SAT&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
}<br />
else                                        //if switch 1 is pressed<br />
{<br />
while(sw1==0)continue;                    //wait switch1 to depress<br />
if(day&gt;6)                                //if day value greater than 11<br />
{<br />
day=1;                                //change setday variable to 1<br />
}<br />
else<br />
{<br />
day+=1;                                //increse day value by 1<br />
}<br />
}<br />
}<br />
if(sw1==0)<br />
{<br />
if(day==7)                                        //overwrite changed day value on LCD<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;SUN&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==1)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;MON&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==2)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;TUE&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==3)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;WED&#8221;);<br />
}<br />
else if(day==4)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;THU&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==5)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;FRI&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
else if(day==6)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;SAT&#8221;);<br />
delay(10000);<br />
lcd_goto(31);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
send_char(&#8216; &#8216;);<br />
delay(10000);<br />
}<br />
}<br />
while(sw0==0)continue;                    //wait switch 0 to be depressed</p>
<p>i2c_rtc_set_seconds(clksec);                //send changed second<br />
i2c_rtc_set_minutes(clkmin);                //send changed minute<br />
i2c_rtc_set_hours(clkhrs);                    //send changed hour<br />
i2c_rtc_set_day(day);                        //send changed day<br />
i2c_rtc_set_date(date);                        //send changed date<br />
i2c_rtc_set_month(month);                    //send changed month<br />
i2c_rtc_set_year(year);                        //send changed year</p>
<p>}</p>
<p>//===================================================================================<br />
// Read RTC function<br />
//===================================================================================</p>
<p>void readrtc(void)<br />
{<br />
while(1)<br />
{<br />
led_yellow=1;<br />
led_white=0;<br />
if(sw0==0)                                //reset button<br />
{<br />
writertc();                            //goto write mode<br />
}<br />
else<br />
{<br />
clksec=uc_i2c_rtc_get_seconds();                    //read 1 byte seconds<br />
clkmin=    uc_i2c_rtc_get_minutes();                    //read 1 byte min<br />
clkhrs=uc_i2c_rtc_get_hours();                        //read 1 byte hrs<br />
day=uc_i2c_rtc_get_day();                            //read 1 byte day<br />
date=uc_i2c_rtc_get_date();                            //read 1 byte date<br />
month=uc_i2c_rtc_get_month();                        //read 1 byte month<br />
year=uc_i2c_rtc_get_year();                            //read 1 byte year</p>
<p>lcd_goto(0);<br />
send_dec(clkhrs,2);</p>
<p>lcd_goto(2);                        //display &#8216;:&#8217;<br />
send_char(0&#215;3A);</p>
<p>lcd_goto(3);<br />
send_dec(clkmin,2);</p>
<p>lcd_goto(5);                        //display &#8216;:&#8217;<br />
send_char(0&#215;3A);</p>
<p>lcd_goto(6);<br />
send_dec(clksec,2);</p>
<p>if(day==7)                            // display day<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;SUN&#8221;);<br />
}<br />
else if(day==1)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;MON&#8221;);<br />
}<br />
else if(day==2)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;TUE&#8221;);<br />
}<br />
else if(day==3)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;WED&#8221;);<br />
}<br />
else if(day==4)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;THU&#8221;);<br />
}<br />
else if(day==5)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;FRI&#8221;);<br />
}<br />
else if(day==6)<br />
{<br />
lcd_goto(31);<br />
send_string(&#8220;SAT&#8221;);<br />
}</p>
<p>lcd_goto(20);                    // display date<br />
send_dec(date,2);</p>
<p>lcd_goto(22);                    //display &#8216;/&#8217;<br />
send_char(0&#215;2F);</p>
<p>lcd_goto(23);                    // display month<br />
send_dec(month,2);</p>
<p>lcd_goto(25);                    // display &#8216;/&#8217;<br />
send_char(0&#215;2F);</p>
<p>lcd_goto(26);                    // display year<br />
send_dec(year,2);</p>
<p>}<br />
}<br />
}</p>
<p>//==========================================================================<br />
//    LCD    functions<br />
//==========================================================================<br />
void delay(unsigned long data)<br />
{<br />
for( ;data&gt;0;data-=1);<br />
}<br />
void send_config(unsigned char data)<br />
{<br />
rs=0;                                        //clear rs into config mode<br />
lcd_data=data;<br />
delay(300);<br />
e_pulse();<br />
}<br />
void send_char(unsigned char data)<br />
{<br />
rs=1;                                        //set rs into write mode<br />
lcd_data=data;<br />
delay(300);<br />
e_pulse();<br />
}<br />
void e_pulse(void)<br />
{<br />
e=1;<br />
delay(300);<br />
e=0;<br />
delay(300);<br />
}<br />
void lcd_goto(unsigned char data)<br />
{<br />
if(data&lt;16)<br />
{<br />
send_config(0&#215;80+data);<br />
}<br />
else<br />
{<br />
data=data-20;<br />
send_config(0xc0+data);<br />
}<br />
}<br />
void lcd_clr(void)<br />
{<br />
send_config(0&#215;01);<br />
delay(350);<br />
}<br />
void send_string(const char *s)<br />
{<br />
unsigned char i=0;<br />
while (s &amp;&amp; *s)send_char (*s++);<br />
}<br />
void send_dec(unsigned long data,unsigned char num_dig)<br />
{</p>
<p>if(num_dig&gt;=10)<br />
{<br />
data=data%10000000000;<br />
send_char(data/1000000000+0&#215;30);<br />
}<br />
if(num_dig&gt;=9)<br />
{<br />
data=data%1000000000;<br />
send_char(data/100000000+0&#215;30);<br />
}<br />
if(num_dig&gt;=8)<br />
{<br />
data=data%100000000;<br />
send_char(data/10000000+0&#215;30);<br />
}<br />
if(num_dig&gt;=7)<br />
{<br />
data=data%10000000;<br />
send_char(data/1000000+0&#215;30);<br />
}<br />
if(num_dig&gt;=6)<br />
{<br />
data=data%1000000;<br />
send_char(data/100000+0&#215;30);<br />
}<br />
if(num_dig&gt;=5)<br />
{<br />
data=data%100000;<br />
send_char(data/10000+0&#215;30);<br />
}<br />
if(num_dig&gt;=4)<br />
{<br />
data=data%10000;<br />
send_char(data/1000+0&#215;30);<br />
}<br />
if(num_dig&gt;=3)<br />
{<br />
data=data%1000;<br />
send_char(data/100+0&#215;30);<br />
}<br />
if(num_dig&gt;=2)<br />
{<br />
data=data%100;<br />
send_char(data/10+0&#215;30);<br />
}<br />
if(num_dig&gt;=1)<br />
{<br />
data=data%10;<br />
send_char(data+0&#215;30);<br />
}<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://widodo.com/teknologi-informasi/display-real-time-clock-rtc-on-lcd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Demo RFID Door Lock berbasis PIC</title>
		<link>http://widodo.com/teknologi-informasi/demo-rfid-door-lock-berbasis-pic/</link>
		<comments>http://widodo.com/teknologi-informasi/demo-rfid-door-lock-berbasis-pic/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 15:55:44 +0000</pubDate>
		<dc:creator>widodo</dc:creator>
				<category><![CDATA[elektronika]]></category>
		<category><![CDATA[teknologi informasi]]></category>

		<guid isPermaLink="false">http://widodo.com/?p=616</guid>
		<description><![CDATA[Sistem keamanan pintu menggunakan RFID, lengkap dengan kode demo dan mikrokontroler PIC.
PR25 is an open source microcontroller Do It Yourself kit. This PIC16F876A microcontroller based project is designed to develop a low cost RFID door lock. It combine the features and functions of PR8 (RFID: Read and Display) and PR9 (Password Door Security). Cytron Technologies [...]]]></description>
			<content:encoded><![CDATA[<p>Sistem keamanan pintu menggunakan RFID, lengkap dengan kode demo dan mikrokontroler PIC.</p>
<p>PR25 is an open source microcontroller Do It Yourself kit. This PIC16F876A microcontroller based project is designed to develop a low cost RFID door lock. It combine the features and functions of PR8 (RFID: Read and Display) and PR9 (Password Door Security). Cytron Technologies uploaded this project with the aim to assist hobbyist and students to pick up embedded system application and development.</p>
<p><strong>Features:</strong></p>
<div>•    Wiegan protocol RFID reader and Tag<br />
•    Magnetic door lock<br />
•    2&#215;16LCD<br />
•    Industrial Grade PCB with proper labeling<br />
•    ICSP socket to ease the loading program<br />
•    Open Source DIY kit (schematic, source code and explanation)<br />
•    Simple, fast and reliable learning tools</div>
<p><img class="alignnone" src="http://cytron.com.my/usr_images/products/screen/2031.jpg" alt="" width="350" height="350" /></p>
<p>Harga kit ini 4.6 juta, Anda pasang sendiri dan dapat USB PIC programmer.</p>
<p><span id="more-616"></span></p>
<p>//==========================================================================<br />
//    Project                : RFID door security<br />
//    Project description    : Scan RFID tag, display ID on the lcd and enable<br />
//                          to save ID<br />
//                          2 ID in this program. 1st already initialize, 2nd ID can be save<br />
//                          Reset will clear the 2nd ID<br />
//                          Only sw1 used in this program.<br />
//==========================================================================</p>
<p>#include &lt;pic.h&gt;</p>
<p>//    configuration<br />
//==========================================================================<br />
__CONFIG ( 0&#215;3F32 );                //configuration for the  microcontroller</p>
<p>//    define<br />
//==========================================================================<br />
#define    rs            RA0                //RS pin of the LCD display<br />
#define    e            RC5                //E pin of the LCD display<br />
#define    b_light        RC4                //backlight of the LCD display (1 to on backlight)<br />
#define relay        RA1                //magnetic lock(active high)<br />
#define    lcd_data    PORTB             //LCD 8-bit data PORT<br />
#define    led            RC3                //led(active high)<br />
#define data0        RC1                //data0(green wire) of RFID reader<br />
#define data1        RC2                //data1(white wire) of RFID reader<br />
#define sw1            RA4                //button to save ID(active low)<br />
#define RX_PIN         RC7                //Rx pin on PIC<br />
#define TX_PIN         RC6                //Tx pin on PIC</p>
<p>//    function prototype                (every function must have a function prototype)<br />
//==========================================================================<br />
void init(void);<br />
void delay(unsigned long data);<br />
void send_config(unsigned char data);<br />
void send_char(unsigned char data);<br />
void send_dec(unsigned long data,unsigned char num_dig);<br />
void e_pulse(void);<br />
void lcd_goto(unsigned char data);<br />
void lcd_clr(void);<br />
void send_string(const char *s);</p>
<p>//    main function                    (main fucntion of the program)<br />
//==========================================================================<br />
void main(void)<br />
{<br />
unsigned char i, repeat, a, b, database;<br />
unsigned char data[26];<br />
unsigned char convert1=0;                            //clear convert1<br />
unsigned int convert2=0;                            //clear convert2<br />
unsigned char mode=0;                                //clear mode<br />
unsigned char id1[2]={127,0};                            //initialize 1st id1 in the array<br />
unsigned int id2[2]={22449,0};                        //initialize 1st id2 in the array</p>
<p>init();                                                //initialization<br />
lcd_clr();                                            //clear the lcd<br />
id1[1]=0;                                            //clear second id1 in the array, first id1 is intialized<br />
id2[1]=0;                                            //clear second id2 in the array, first id2 is intialized<br />
b_light=1;                                            //on the back light<br />
lcd_goto(0);                                        //set the lcd cursor to location 0<br />
send_string (&#8221; RFID door&#8221;);                            //display &#8221; RFID door&#8221;<br />
lcd_goto(20);                                        //set the lcd cursor to location 20<br />
send_string (&#8221; security&#8221;);                            //display &#8221; security&#8221;</p>
<p>for(repeat=12; repeat&gt;0; repeat&#8211;)                    //repeat delay(1000000)for 12 times<br />
{<br />
delay(1000000);<br />
}</p>
<p>while(1)<br />
{<br />
convert1=0;                                                //clear convert1<br />
convert2=0;                                                //clear convert2</p>
<p>lcd_clr();                                                //clear the lcd<br />
lcd_goto(0);                                            //set the lcd cursor to location 0<br />
send_string (&#8220;Place your tag&#8221;);                            //display &#8220;Place your tag&#8221;<br />
lcd_goto(20);                                            //set the lcd cursor to location 20<br />
send_string (&#8220;on the reader&#8221;);                            //display &#8220;on the reader&#8221;</p>
<p>while(mode==0)                                            //no RFID tag is placed on RFID reader<br />
{<br />
if((data0==0)||(data1==0))     mode=1;                    //RFID tag is placed on RFID reader (receive data stream from RFID tag)<br />
else if(sw1==0)    mode=2;                                //push button is pressed, enter to save mode<br />
}</p>
<p>//RFID tag is placed on RFID reader (RFID reader receive data stream from RFID tag)<br />
while(mode==1)<br />
{<br />
if((data0==0)&amp;&amp;(data1==1))                            //if data0 changes (data0 is active low)<br />
{<br />
data[i]=0;                                        //save that the bit received is 0<br />
while((data0==0)&amp;&amp;(data1==1));                    //wait until data0 back to high logic<br />
}<br />
else if ((data0==1)&amp;&amp;(data1==0))                    //if data1 changes (data1 is active low)<br />
{<br />
data[i]=1;                                        //save that the bit received is 1<br />
while((data0==1)&amp;&amp;(data1==0));                    //wait until data1 back to high logic<br />
}<br />
i+=1;                                                //i+1</p>
<p>while(i&lt;26)                                            //repeat the loop until all 26 bit data are sent (start from 0 to 25)<br />
{<br />
while((data0==1)&amp;&amp;(data1==1));                    //wait while data0 and data1 remain at high logic level (no changes at data0 and data1)<br />
if((data0==0)&amp;&amp;(data1==1))                        //if data0 changes (data0 is active low)<br />
{<br />
data[i]=0;                                    //save that the bit received is 0<br />
while((data0==0)&amp;&amp;(data1==1));                //wait for data stream finish sending from RFID tag again (data0 or data1 will back to high logic)<br />
}<br />
else if ((data0==1)&amp;&amp;(data1==0))                //if data1 received is 0 (data1 is active low)<br />
{<br />
data[i]=1;                                    //save that the bit received is 1<br />
while((data0==1)&amp;&amp;(data1==0));                //wait for data stream finish sending from RFID tag again (data0 or data1 will back to high logic)<br />
}<br />
i+=1;                                            //i+1<br />
}</p>
<p>mode=0;                                                            //after all data are sent, reset as no RFID tag is placed on RFID reader<br />
//no data stream received from RFID tag<br />
i=0;                                                            //clear i<br />
lcd_clr();                                                        //clear the lcd</p>
<p>for(i=0;i&lt;8;i++)                                                //loop for data[0]-data[7]<br />
{<br />
convert1=(convert1&lt;&lt;1)|data[i+1];                            //shift current data and combine with previous data, store data in convert1            }<br />
}<br />
for(i=0;i&lt;16;i++)                                                //loop for data[8]-data[25]<br />
{<br />
convert2=(convert2&lt;&lt;1)|data[i+9];                            //shift current data and combine with previous data, store data in convert2<br />
}</p>
<p>for(b=0;b&lt;2;b++)                                                //compare with id[0] and id[1]<br />
{<br />
if((convert1==id1[b])&amp;&amp;(convert2==id2[b])) database=1;        //id doesn&#8217;t match, set database to 1<br />
}<br />
lcd_clr();                                                        //clear the lcd<br />
}</p>
<p>//push button is pressed, enter to save mode<br />
while(mode==2)<br />
{<br />
lcd_clr();                                            //clear the lcd<br />
lcd_goto(0);                                        //set the lcd cursor to location 0<br />
send_string (&#8220;    Save mode   &#8220;);                        //display &#8221; Save mode &#8221;<br />
lcd_goto(20);                                        //set the lcd cursor to location 0<br />
send_string (&#8221; Place your tag&#8221;);                        //display &#8221; Save mode &#8221;</p>
<p>while(i&lt;26)                                            //loop for data less than 26<br />
{<br />
while((data0==1)&amp;&amp;(data1==1));                    //wait for data0 and data1 to change<br />
if((data0==0)&amp;&amp;(data1==1))                        //if data0 changes (data0 is active low)<br />
{<br />
data[i]=0;                                    //save that the bit received is 0<br />
while((data0==0)&amp;&amp;(data1==1));                //wait until data0 and data1 back to high logic<br />
}<br />
else if ((data0==1)&amp;&amp;(data1==0))                //if data1 changes (data1 is active low)<br />
{<br />
data[i]=1;                                    //save that the bit received is 1<br />
while((data0==1)&amp;&amp;(data1==0));                //wait until data0 and data1 back to high logic<br />
}<br />
i+=1;                                            //i+1<br />
}</p>
<p>mode=0;                                                //clear mode<br />
i=0;                                                //clear i<br />
lcd_clr();                                            //clear the lcd</p>
<p>for(i=0;i&lt;8;i++)                                    //loop for data[0]-data[7]<br />
{<br />
convert1=(convert1&lt;&lt;1)|data[i+1];                //shift previous data and combine with present data<br />
}<br />
for(i=0;i&lt;16;i++)                                    //loop for data[8]-data[25]<br />
{<br />
convert2=(convert2&lt;&lt;1)|data[i+9];                //shift previous data and combine with present data<br />
}</p>
<p>id1[1]=convert1;                                    //save convert1 to id1<br />
id2[1]=convert2;                                    //save convert2 to id2</p>
<p>database=2;                                            //display ID no. and &#8220;User ID saved&#8221; on LCD<br />
lcd_clr();                                            //clear the lcd<br />
}</p>
<p>switch(database)<br />
{<br />
case 1:                                                //id 1 match<br />
relay=1;                                        //door lock released<br />
led=0;                                            //led off<br />
lcd_goto(0);                                    //set lcd cursor to location 0<br />
send_string(&#8220;ID no: &#8220;);                            //display &#8220;ID no: &#8221;<br />
lcd_goto(7);                                    //set lcd cursor to location 7<br />
send_dec(convert1,3);                            //display convert1 in 3 decimal number<br />
lcd_goto(10);                                    //set lcd cursor to location 10<br />
send_dec(convert2,5);                            //display convert2 in 5 decimal number<br />
lcd_goto(20);                                    //set lcd cursor to location 20<br />
send_string(&#8220;User identified. &#8220;);                //display &#8220;User identified.&#8221;<br />
for(repeat=12; repeat&gt;0; repeat&#8211;)                //repeat delay(100000) for 12 times<br />
{<br />
delay(1000000);<br />
}<br />
lcd_clr();                                        //clear the LCD<br />
lcd_goto(0);                                    //set lcd cursor to location 0<br />
send_string(&#8220;Door lock will&#8221;);                     //display &#8220;Door lock will be locked in&#8221;<br />
lcd_goto(20);<br />
send_string(&#8220;be locked in &#8220;);</p>
<p>for(a=5;a&gt;0;a&#8211;)                                //display number from 5 to 1<br />
{<br />
lcd_goto(34);                                //set lcd cursor to location 34<br />
send_dec(a, 1);                                //display a in 1 decimal number<br />
for(repeat=10; repeat&gt;0; repeat&#8211;)            //repeat delay(100000) for 10 times<br />
{<br />
delay(1000000);<br />
}<br />
}<br />
break;</p>
<p>case 2:                                                //save id<br />
relay=1;                                        //door lock released<br />
led=0;                                            //led off<br />
lcd_clr();                                        //clear lcd<br />
lcd_goto(0);                                    //set lcd cursor to location 0<br />
send_string(&#8220;ID no: &#8220;);                            //display &#8220;ID no: &#8221;<br />
lcd_goto(7);                                    //set lcd cursor to location 7<br />
send_dec(convert1,3);                            //display convert1 in 3 decimal number<br />
lcd_goto(10);                                    //set lcd cursor to location 10<br />
send_dec(convert2,5);                            //display convert2 in 5 decimal number<br />
lcd_goto(20);                                    //set lcd cursor to location 20<br />
send_string(&#8220;User ID saved.&#8221;);                    //display &#8220;User ID saved.&#8221;<br />
break;</p>
<p>default:                                            //id doesnt match<br />
relay=0;                                        //door lock locked<br />
led=1;                                            //led light on<br />
lcd_goto(0);                                    //set lcd cursor to location 0<br />
send_string(&#8220;ID no: &#8220;);                            //display &#8220;ID no: &#8221;<br />
lcd_goto(7);                                    //set lcd cursor to location 7<br />
send_dec(convert1,3);                            //display convert in 3 decimal number<br />
lcd_goto(10);                                    //set lcd cursor to location 10<br />
send_dec(convert2,5);                            //display convert in 5 decimal number<br />
lcd_goto(20);                                    //set lcd cursor to location 20<br />
send_string(&#8220;User not found.&#8221;);                    //display &#8220;User not found.&#8221;<br />
break;<br />
}</p>
<p>for(repeat=12; repeat&gt;0; repeat&#8211;)                        //repeat delay(100000) for 12 times<br />
{<br />
delay(1000000);<br />
}</p>
<p>i=0;                                                    //clear i<br />
led=0;                                                    //led off<br />
database=0;                                                //no action taken, no RFID tag is placed on RFID reader<br />
relay=0;                                                //off door lock<br />
convert1=0;                                                //clear convert1<br />
convert2=0;                                                //clear convert2<br />
}<br />
}</p>
<p>// Initailization<br />
//============================================================================================================<br />
void init()<br />
{<br />
//SET PORT A AS DIGITAL<br />
ADCON1 = 0X06;                                            //default all analog pin as digital</p>
<p>// Tris configuration (input or output)<br />
TRISA = 0b00111100;                                        //set RA2, RA3, RA4, and RA5 as input, else as output<br />
TRISB = 0b00000000;                                        //set all PORTB pin as output<br />
TRISC = 0b00000111;                                        //set RC0 and RC1 as input, else as output</p>
<p>// LCD configuration<br />
send_config(0b00000001);                                //clear display at lcd<br />
send_config(0b00000010);                                //Lcd Return to home<br />
send_config(0b00000110);                                //entry mode-cursor increase 1<br />
send_config(0b00001100);                                //diplay on, cursor off and cursor blink off<br />
send_config(0b00111000);                                //function</p>
<p>b_light=0;                                                //on lcd back light<br />
delay(5000);                                            //delay<br />
led=0;                                                    //off led<br />
relay=0;                                                //off door lock<br />
}</p>
<p>//    LCD    functions<br />
//============================================================================================================<br />
void delay(unsigned long data)                                //delay function, the delay time<br />
{<br />
int i;<br />
for( i = data; i&gt;0; i&#8211;);                                //depend on the given value<br />
}</p>
<p>void send_config(unsigned char data)                        //send lcd configuration<br />
{<br />
rs=0;                                                    //set lcd to config mode<br />
lcd_data=data;                                            //lcd data port = data<br />
delay(400);<br />
e_pulse();                                                //pulse e to confirm the data<br />
}</p>
<p>void send_char(unsigned char data)                            //send lcd character<br />
{<br />
rs=1;                                                    //set lcd to display mode<br />
lcd_data = data;                                        //lcd data port = data<br />
delay(400);<br />
e_pulse();                                                //pulse e to confirm the data<br />
}</p>
<p>void send_dec(unsigned long data,unsigned char num_dig)        //convert binary number and display number in decimal<br />
{<br />
if(num_dig&gt;=10)<br />
{<br />
data=data%10000000000;<br />
send_char(data/1000000000+0&#215;30);<br />
}<br />
if(num_dig&gt;=9)<br />
{<br />
data=data%1000000000;<br />
send_char(data/100000000+0&#215;30);<br />
}<br />
if(num_dig&gt;=8)<br />
{<br />
data=data%100000000;<br />
send_char(data/10000000+0&#215;30);<br />
}<br />
if(num_dig&gt;=7)<br />
{<br />
data=data%10000000;<br />
send_char(data/1000000+0&#215;30);<br />
}<br />
if(num_dig&gt;=6)<br />
{<br />
data=data%1000000;<br />
send_char(data/100000+0&#215;30);<br />
}<br />
if(num_dig&gt;=5)<br />
{<br />
data=data%100000;<br />
send_char(data/10000+0&#215;30);<br />
}<br />
if(num_dig&gt;=4)<br />
{<br />
data=data%10000;<br />
send_char(data/1000+0&#215;30);<br />
}<br />
if(num_dig&gt;=3)<br />
{<br />
data=data%1000;<br />
send_char(data/100+0&#215;30);<br />
}<br />
if(num_dig&gt;=2)<br />
{<br />
data=data%100;<br />
send_char(data/10+0&#215;30);<br />
}<br />
if(num_dig&gt;=1)<br />
{<br />
data=data%10;<br />
send_char(data+0&#215;30);<br />
}<br />
}</p>
<p>void e_pulse(void)                                        //pulse e to confirm the data<br />
{<br />
e=1;<br />
delay(300);<br />
e=0;<br />
delay(300);<br />
}</p>
<p>void lcd_goto(unsigned char data)                        //set the location of the lcd cursor<br />
{<br />
if(data&lt;16)                                            //if the given value is (0-15) the<br />
{                                                    //cursor will be at the upper line<br />
send_config(0&#215;80+data);<br />
}<br />
else                                                //if the given value is (20-35) the<br />
{                                                    //cursor will be at the lower line<br />
data=data-20;                                    //location of the lcd cursor(2X16):<br />
send_config(0xc0+data);                            // &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
}                                                    // | |00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15| |<br />
}                                                        // | |20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35| |<br />
// &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>void lcd_clr(void)                                        //clear the lcd<br />
{<br />
send_config(0&#215;01);<br />
delay(350);<br />
}</p>
<p>void send_string(const char *s)                         //send a string to display in the lcd<br />
{<br />
while (s &amp;&amp; *s)send_char (*s++);<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://widodo.com/teknologi-informasi/demo-rfid-door-lock-berbasis-pic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sistem Alarm Kebakaran dengan Sensor Asap MQ2</title>
		<link>http://widodo.com/elektronika/sistem-alarm-kebakaran-dengan-sensor-asap-mq2/</link>
		<comments>http://widodo.com/elektronika/sistem-alarm-kebakaran-dengan-sensor-asap-mq2/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 06:48:18 +0000</pubDate>
		<dc:creator>widodo</dc:creator>
				<category><![CDATA[elektronika]]></category>

		<guid isPermaLink="false">http://widodo.com/?p=584</guid>
		<description><![CDATA[Sistem alarm kebakaran dapat dibangun dengan mikrokontroler AVR serta sensor Asap MQ-2.   Sensor gas dan asap ini mendeteksi konsentrasi gas yang  mudah terbakar di udara serta asap dan ouputs membaca sebagai tegangan analog. Sensor dapat mengukur konsentrasi gas mudah terbakar dari 300 sampai 10.000 sensor ppm. Dapat beroperasi pada suhu dari -20 sampai 50 [...]]]></description>
			<content:encoded><![CDATA[<p>Sistem alarm kebakaran dapat dibangun dengan mikrokontroler AVR serta sensor Asap MQ-2.   Sensor gas dan asap ini mendeteksi konsentrasi gas yang  mudah terbakar di udara serta asap dan ouputs membaca sebagai tegangan analog. Sensor dapat mengukur konsentrasi gas mudah terbakar dari 300 sampai 10.000 sensor ppm. Dapat beroperasi pada suhu dari -20 sampai 50 ° C dan mengkonsumsi kurang dari 150 mA pada 5V <a href="http://widodo.com/wp-content/uploads/2011/10/mq-21.jpg"><img class="aligncenter size-full wp-image-586" title="mq-2" src="http://widodo.com/wp-content/uploads/2011/10/mq-21.jpg" alt="" width="250" height="250" /></a></p>
<p><a href="http://widodo.com/wp-content/uploads/2011/10/gambarmq22.jpg"><img class="alignleft size-large wp-image-597" title="gambarmq2" src="http://widodo.com/wp-content/uploads/2011/10/gambarmq22-1024x341.jpg" alt="" width="823" height="274" /></a></p>
<p><em><strong> Sensor Metana dan Asap MQ-2 dan rangkaian dasar </strong></em></p>
<p>Anda dapat memiliki kode demo dan paket kit sudah jadi untuk Sistem alarm kebakaran ini seharga RP 5.000.000, silahkan kontak MR. Widodo di 081410043883 atau widodo@widodo.com</p>
<p>Datasheet ssensor ini dapat dilihat di <a href="http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/MQ-2.pdf">sini </a></p>
]]></content:encoded>
			<wfw:commentRss>http://widodo.com/elektronika/sistem-alarm-kebakaran-dengan-sensor-asap-mq2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Programming</title>
		<link>http://widodo.com/mata-kuliah/web-programming/</link>
		<comments>http://widodo.com/mata-kuliah/web-programming/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 04:28:00 +0000</pubDate>
		<dc:creator>widodo</dc:creator>
				<category><![CDATA[mata kuliah]]></category>
		<category><![CDATA[teknologi informasi]]></category>

		<guid isPermaLink="false">http://widodo.com/?p=551</guid>
		<description><![CDATA[Dr. Widodo Budiharto
08569887384

Pert 1.  Intro Web Programming. Materi tambahan Web
Pert 2.  Intro Java Programming. Materi tambahan Web (penting)
Pert 4. Javascript Application
Pert 5. Internet and WWW
Pert 6. Servlet Programming    Java full packages  NILAI UTS
Pert 7. Web Application with Servlet
Pert 8. JSP Fundamental
Pert 9. JSP Advance (JSTL) Materi JSTL Download Kode TM2
]]></description>
			<content:encoded><![CDATA[<p><span id="more-551"></span>Dr. Widodo Budiharto</p>
<p>08569887384</p>
<p><a href="http://widodo.com/wp-content/uploads/2011/09/396098_10150525459402298_782952297_8576799_767573341_n1.jpg"><img class="alignleft size-full wp-image-704" title="396098_10150525459402298_782952297_8576799_767573341_n" src="http://widodo.com/wp-content/uploads/2011/09/396098_10150525459402298_782952297_8576799_767573341_n1.jpg" alt="" width="397" height="297" /></a></p>
<p><a href="http://widodo.com/wp-content/uploads/2011/09/web1.ppt">Pert 1</a>.  Intro Web Programming. <a href="http://widodo.com/wp-content/uploads/2011/09/TrainingJSP.pptx">Materi tambahan Web</a></p>
<p>Pert 2.  Intro Java Programming. <a href="http://toko-elektronika.com/kuliah/bagian1.doc">Materi tambahan Web</a> (penting)</p>
<p>Pert 4. Javascript Application</p>
<p><a href="http://toko-elektronika.com/kuliah/webprog5.pptx">Pert 5.</a> Internet and WWW</p>
<p><a href="http://toko-elektronika.com/kuliah/webprog6.pptx">Pert 6.</a> Servlet Programming    <a href="http://toko-elektronika.com/kuliah/javafullpackages.pptx">Java full packages</a> <a href="http://toko-elektronika.com/kuliah/utswebprog2011.htm"> NILAI UTS</a></p>
<p>Pert 7. Web Application with Servlet</p>
<p>Pert 8. JSP Fundamental</p>
<p>Pert 9. <a href="http://toko-elektronika.com/kuliah/webprog9.zip">JSP Advance (JSTL)</a> <a href="http://toko-elektronika.com/kuliah/jsp2_ch11.pdf">Materi JSTL</a> <a href="http://toko-elektronika.com/kuliah/jstl.zip">Download Kode TM2</a></p>
]]></content:encoded>
			<wfw:commentRss>http://widodo.com/mata-kuliah/web-programming/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Algoritma dan Object Oriented Programming</title>
		<link>http://widodo.com/mata-kuliah/algoritma-dan-metode-oop/</link>
		<comments>http://widodo.com/mata-kuliah/algoritma-dan-metode-oop/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 04:53:12 +0000</pubDate>
		<dc:creator>widodo</dc:creator>
				<category><![CDATA[mata kuliah]]></category>
		<category><![CDATA[teknologi informasi]]></category>

		<guid isPermaLink="false">http://widodo.com/?p=538</guid>
		<description><![CDATA[Algoritma dan OOP
Widodo Budiharto, PhD
08569887384
Book: 
Liang, Y.D.                                      (2011).             [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span id="more-538"></span>Algoritma dan OOP</strong></p>
<p>Widodo Budiharto, PhD</p>
<p>08569887384</p>
<p><strong>Book: </strong></p>
<p>Liang, Y.D.                                      (2011).                                      <strong>Introduction to Java programming</strong>.  9th Edition.                                      Pearson Education.                                      New Jersey.                                       ISBN: 0-136059660.</p>
<p><a href="http://widodo.com/wp-content/uploads/2011/09/moop1.ppt">Pert 1</a> Pengantar Algoritma dan Java</p>
<p><a href="http://toko-elektronika.com/kuliah/prog2.ppt">Pert 2. </a>Pengenalan Java</p>
<p><a href="http://toko-elektronika.com/kuliah/algo3.pptx">Pert 3.</a> Input/output dan datatype</p>
<p><a href="http://toko-elektronika.com/kuliah/algo4.pptx">Pert 4.</a> Arithmetic</p>
<p><a href="http://toko-elektronika.com/kuliah/algo5.pptx">Pert 5.</a> Logic</p>
<p><a href="http://toko-elektronika.com/kuliah/algo6.ppt">Pert 6</a>. Selection Statements</p>
<p><a href="http://toko-elektronika.com/kuliah/algo7.ppt">Pert 7.</a> Iteration    <a href="http://toko-elektronika.com/kuliah/PersiapanUTSAlgo.pptx">Persiapan UTS</a> <a href="http://toko-elektronika.com/kuliah/algo2011UTS.htm"><strong>NILAI UTS</strong></a></p>
<p><a href="http://toko-elektronika.com/kuliah/sort.ppt">Pert 12.</a> Sort</p>
<p>Pert 13.</p>
<p><a href="http://toko-elektronika.com/kuliah/ReviewUASAlgo.pptx">ReviewUAS</a></p>
]]></content:encoded>
			<wfw:commentRss>http://widodo.com/mata-kuliah/algoritma-dan-metode-oop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Konsep Bahasa Pemrograman</title>
		<link>http://widodo.com/mata-kuliah/konsep-bahasa-pemrograman/</link>
		<comments>http://widodo.com/mata-kuliah/konsep-bahasa-pemrograman/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 04:48:21 +0000</pubDate>
		<dc:creator>widodo</dc:creator>
				<category><![CDATA[mata kuliah]]></category>
		<category><![CDATA[teknologi informasi]]></category>

		<guid isPermaLink="false">http://widodo.com/?p=536</guid>
		<description><![CDATA[Konsep Bahasa Pemrograman
Widodo Budiharto, PhD
Book :
Sebesta, R.W.                                      (2010).             [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span id="more-536"></span>Konsep Bahasa Pemrograman</strong></p>
<p>Widodo Budiharto, PhD</p>
<p>Book :</p>
<p>Sebesta, R.W.                                      (2010).                                      <strong>Concept of Programming Languages</strong>.                                      9th edition.                                      Pearson.                                      New Jersey.                                       ISBN: 0-13-246558-2.</p>
<p><a href="http://widodo.com/wp-content/uploads/2011/09/kbp1.ppt">Pert 1.</a> Pengantar Konsep Bahasa Pemrograman</p>
<p><a href="http://toko-elektronika.com/kuliah/kbp2.ppt">Pert 2</a>.  Describing syntax and semantics</p>
<p><a href="http://toko-elektronika.com/kuliah/kbp3.ppt">Pert 3.</a> Names , binding and scopes</p>
<p><a href="http://toko-elektronika.com/kuliah/kbp4.pptx">Pert 4.</a> Data Types</p>
<p><a href="http://toko-elektronika.com/kuliah/kbp5.pptx">Pert 5.</a> Expression and Assignment statements</p>
<p>Pert 6.</p>
<p><a href="http://toko-elektronika.com/kuliah/kbp7.pptx">Pert 7</a>.  Subprogram   <a href="http://toko-elektronika.com/kuliah/kbp2011.htm">Nilai UTS</a></p>
<p>Pert 8.</p>
<p>Pert 9. <a href="http://toko-elektronika.com/kuliah/kbp9.zip"> Konsep OOP</a></p>
<p>pert 10. <a href="http://toko-elektronika.com/kuliah/quizkbp.pptx">Concurrency</a></p>
]]></content:encoded>
			<wfw:commentRss>http://widodo.com/mata-kuliah/konsep-bahasa-pemrograman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Teori Bahasa dan Automata</title>
		<link>http://widodo.com/mata-kuliah/teori-bahasa-dan-automata/</link>
		<comments>http://widodo.com/mata-kuliah/teori-bahasa-dan-automata/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 04:44:32 +0000</pubDate>
		<dc:creator>widodo</dc:creator>
				<category><![CDATA[mata kuliah]]></category>
		<category><![CDATA[teknologi informasi]]></category>

		<guid isPermaLink="false">http://widodo.com/mata-kuliah/teori-bahasa-dan-automata/</guid>
		<description><![CDATA[Widodo Budiharto, PhD
08569887384
book :
Hopcroft dkk, Introduction to Automata Theory, Languages and Computation, Addison –Wesley, 2001

RANGKUMAN (mohon dipelajari)
Pert. 1 Intro Teori Bahasa dan Automata
Pert. 2 Finite Automata          Contoh  DFA
Pert 3. DFA
Pert 4. NFA  Advanced DFA &#38; NFA
Pert 5. NFA with empty string translation  RE ke e-NFA ke DFA minimisasi
Pert 6. Minimisasi  DFA   Konversi e-NFA Telusuri string [...]]]></description>
			<content:encoded><![CDATA[<p>Widodo Budiharto, PhD</p>
<p>08569887384</p>
<p>book :</p>
<p>Hopcroft dkk, Introduction to Automata Theory, Languages and Computation, Addison –Wesley, 2001</p>
<p><span id="more-535"></span></p>
<p><a href="http://toko-elektronika.com/kuliah/TeoriBahasaAutomata.pdf">RANGKUMAN </a>(mohon dipelajari)</p>
<p><a href="http://widodo.com/wp-content/uploads/2011/09/bahasa1.ppt">Pert. 1</a> Intro Teori Bahasa dan Automata</p>
<p><a href="http://www.toko-elektronika.com/kuliah/bahasa2.pptx">Pert. 2</a> Finite Automata         <a href="http://toko-elektronika.com/kuliah/DFA.pdf"> Contoh  DFA</a></p>
<p>Pert 3. DFA</p>
<p><a href="http://toko-elektronika.com/kuliah/bahasa4.ppt">Pert 4.</a> NFA  <a href="http://toko-elektronika.com/kuliah/dfanfa.ppt">Advanced DFA &amp; NFA</a></p>
<p><a href="http://toko-elektronika.com/kuliah/bahasa5.pptx">Pert 5.</a> NFA with empty string translation  <a href="http://toko-elektronika.com/kuliah/RENFADFAMINIMISASI.pdf">RE ke e-NFA ke DFA minimisasi</a></p>
<p><a href="http://toko-elektronika.com/kuliah/automata6.ppt">Pert 6.</a> Minimisasi  DFA   <a href="http://toko-elektronika.com/kuliah/konversi.pptx">Konversi e-NFA Telusuri string ke DFA</a></p>
<p><a href="http://toko-elektronika.com/kuliah/automata7.pptx">Pert 7.</a> DFA output     <a href="http://toko-elektronika.com/kuliah/REviewerMateriAutomata.pptx">RewiewMateriPengayaanUTS </a></p>
<p><a href="http://toko-elektronika.com/kuliah/PersiapanUTSBahasa.pptx">Persiapan UTS</a> <a href="http://toko-elektronika.com/kuliah/utsbahasa2011.htm">NILAI UTS</a></p>
<p>Pert  8. Context free language  <a href="http://toko-elektronika.com/kuliah/quiz2.pptx">Quiz</a></p>
<p>Pert 9 Ambiguous Grammar</p>
<p><a href="http://toko-elektronika.com/kuliah/comsky2.ppt">Pert 10.</a> Bentuk Normal Chomsky dan Greibach  <a href="http://toko-elektronika.com/kuliah/cnfgnf.pdf">Tutorial tambahan</a></p>
<p><a href="http://toko-elektronika.com/kuliah/pda.ppt">Pert 11.</a> Push down automata dan NPDA . <a href="http://toko-elektronika.com/kuliah/pda.doc">Materi lengkap PDA</a> <a href="http://toko-elektronika.com/kuliah/tugas3.pptx">Tugas</a></p>
]]></content:encoded>
			<wfw:commentRss>http://widodo.com/mata-kuliah/teori-bahasa-dan-automata/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Kendali Alat dengan Remote TV , Mikro AVR &amp; Relay Board</title>
		<link>http://widodo.com/elektronika/kendali-alat-dengan-remote-tv/</link>
		<comments>http://widodo.com/elektronika/kendali-alat-dengan-remote-tv/#comments</comments>
		<pubDate>Sat, 21 May 2011 05:05:40 +0000</pubDate>
		<dc:creator>widodo</dc:creator>
				<category><![CDATA[elektronika]]></category>

		<guid isPermaLink="false">http://widodo.com/?p=499</guid>
		<description><![CDATA[Mengendalikan dengan menggunakan remote kontrol inframerah merupakan fasilitas yang harus dimiliki semua perangkat elektronik untuk saat ini. Bisa kita lihat bahwa sebagian besar TV, Audio, Tape Recorder, VCD, DVD sudah dilengkapi dengan remote kontrol. Teknologi ini sebenarnya bisa diaplikasikan dimana saja termasuk untuk mengendalikan lampu dalam rumah, sehingga apabila menyalakan atau mematikan lampu tanpa harus [...]]]></description>
			<content:encoded><![CDATA[<p>Mengendalikan dengan menggunakan remote kontrol inframerah merupakan fasilitas yang harus dimiliki semua perangkat elektronik untuk saat ini. Bisa kita lihat bahwa sebagian besar TV, Audio, Tape Recorder, VCD, DVD sudah dilengkapi dengan remote kontrol. Teknologi ini sebenarnya bisa diaplikasikan dimana saja termasuk untuk mengendalikan lampu dalam rumah, sehingga apabila menyalakan atau mematikan lampu tanpa harus menekan saklar yang terdapat pada dinding tapi cukup dengan remote kontrol saja. Hal ini dikarenakan kecenderungan manusia untuk selalu mencari kemudahan dengan memanfaatkan teknologi.</p>
<p>Berikut ini gambar alat jadi :</p>
<p><img class="alignnone" src="http://toko-elektronika.com/img/foto/266307_10150250300747298_782952297_7188320_4414827_o.jpg" alt="" width="356" height="589" /></p>
<p><img class="alignnone" src="http://widodo.com/wp-content/uploads/2011/05/model.jpg" alt="" width="325" height="95" /></p>
<p><strong><em>Gambar 1 Blok Diagram Rangkaian</em></strong></p>
<p><strong><em><span id="more-499"></span><br />
</em></strong></p>
<p>Remote kontrol atau adalah suatu perangkat yang terdapat berbagai tombol  untuk mengendalikan sesuatu secara wireless dengan menggunakan media  inframerah. Sebagian besar produsen perangkat elektronik telah  mengeluarkan remote control untuk pengendalinya. Masing-masing produsen  tersebut mempunyai beberapa standar.</p>
<p>Standar Remote Kontrol yang mudah untuk dimengerti dan diaplikasikan adalah standar SIRC (<em>Sony Infrared Remote Control) </em>atau lebih dikenal dengan standar SONY. Bagian terkecil dari sinyal pembacaan pada standar ini adalah <strong>T</strong> yang memiliki periode sebesar 600us.</p>
<p>Sistem pengkodean yang digunakan pada remote kontrol standar SONY ini adalah <strong><em>Pulse Code</em></strong>, jadi yang membedakan logika <em>high </em>atau <em>low </em>terletak pada panjang pulsanya.</p>
<p><img class="alignnone" src="http://widodo.com/wp-content/uploads/2011/05/sinyal.jpg" alt="" width="421" height="170" /></p>
<p><strong><em>Gambar 2  Bentuk Gelombang Transmit Remote SONY</em></strong></p>
<p><strong><em><br />
</em></strong></p>
<p><strong><em>Aplikasi Penerima dengan AVR</em></strong></p>
<p>Pemrograman mikrokontroller AVR  sebagai penerima remote standar SIRC ini tekniknya sama seperti teknik pembacaan diatas tapi masih perlu beberapa penyesuaian agar didapatkan hasil yang maksimal. Penyesuaian tersebut perlu dilakukan karena ada beberapa hal yang mempengaruhi diantaranya adalah kecepatan mikrokontroller serta komponen yang digunakan. Dalam penyesuaian ini yang dilakukan hanya menambah atau mengurangi sedikit dari timer, yang digunakan untuk mendeteksi periode pulsa yang diterima. Berikut ini akan disampaikan program dengan menggunakan codevision untuk mendeteksi pulsa yang diterima untuk remote jenis SONY atau SIRC.</p>
<p><strong><em>Pembacaan Remote Standar SONY</em></strong></p>
<p>Teknik pembacaan untuk standar ini adalah sebagai berikut:</p>
<ol>
<li>Deteksi pulsa      low selama 2400 ms apabila tidak sama maka bukan standar SIRC.</li>
<li>Deteksi pulsa      low untuk level logika, apabila 0.6 ms = ‘0’ tapi apabila 1.2 ms = ‘1’.</li>
<li>Untuk no. 2      ulangi sebanyak 12 kali dan simpan hasilnya.</li>
</ol>
<p><strong><em>Aplikasi Penerima dengan ATmega8535</em></strong></p>
<p>Pemrograman mikrokontroller ATmega8535 sebagai penerima remote standar SIRC ini tekniknya sama seperti teknik pembacaan diatas tapi masih perlu beberapa penyesuaian agar didapatkan hasil yang maksimal. Penyesuaian tersebut perlu dilakukan karena ada beberapa hal yang mempengaruhi diantaranya adalah kecepatan mikrokontroller serta komponen yang digunakan. Dalam penyesuaian ini yang dilakukan hanya menambah atau mengurangi sedikit dari timer, yang digunakan untuk mendeteksi periode pulsa yang diterima. Berikut ini akan disampaikan program dengan menggunakan codevision untuk mendeteksi pulsa yang diterima untuk remote jenis SONY atau SIRC.</p>
<p>Project : Pengendali Lampu dengan Remote SONY</p>
<p>#include &lt;mega32.h&gt;</p>
<p>#include &lt;stdio.h&gt;</p>
<p>#include &lt;delay.h&gt;</p>
<p>unsigned char count, data1, data2, data3,data4, data5, data6, data7, data8;</p>
<p>unsigned char data11, data12, data13, data14;</p>
<p>unsigned char start, ir_data;</p>
<p>void main(void)</p>
<p>{</p>
<p>// Declare your local variables here</p>
<p>// Input/Output Ports initialization</p>
<p>// Port A initialization</p>
<p>// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In</p>
<p>// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T</p>
<p>PORTA=0&#215;00;</p>
<p>DDRA=0&#215;00;</p>
<p>// Port B initialization</p>
<p>// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In</p>
<p>// State7=T State6=T State5=T State4=T State3=T State2=T State1=P State0=P</p>
<p>PORTB=0&#215;03;//Resitor Pull up aktif</p>
<p>DDRB=0&#215;00;//Port B input</p>
<p>// Port C initialization</p>
<p>// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out</p>
<p>// State7=1 State6=1 State5=1 State4=1 State3=1 State2=1 State1=1 State0=1</p>
<p>PORTC=0xFF;// Resitor Pull up aktif</p>
<p>DDRC=0xFF;//Port C output untuk mengendalikan lampu</p>
<p>// Port D initialization</p>
<p>// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In</p>
<p>// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T</p>
<p>PORTD=0&#215;00;</p>
<p>DDRD=0&#215;00;</p>
<p>while (1)</p>
<p>{</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>start=count;</p>
<p>count=0;</p>
<p>if (start==24) //jika header sama dengan 24 eksekusi program dibawah</p>
<p>{              //ini jika tidak abaikan data tersebut</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data1=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data2=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data3=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data4=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data5=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data6=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data7=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data8=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data11=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data12=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data13=count;</p>
<p>count=0;</p>
<p>while (PINB.0==1) {};</p>
<p>while (PINB.0==0)</p>
<p>{</p>
<p>delay_us(100);</p>
<p>count++;</p>
<p>};</p>
<p>data14=count;</p>
<p>count=0;</p>
<p>data1=((data1/5)-1)*1;//data hasil deteksi pulsa dibagi 5 dikurangi 1</p>
<p>data2=((data2/5)-1)*2;//jadi jika datanya 6 maka outputnya akan = 0</p>
<p>data3=((data3/5)-1)*4;//sedangkan jika datanya 12 maka outputnya akan = 1</p>
<p>data4=((data4/5)-1)*8;//lalu hasil tersebut dikalikan dengan nilai masing-masing bit</p>
<p>data5=((data5/5)-1)*16;</p>
<p>data6=((data6/5)-1)*32;</p>
<p>data7=((data7/5)-1)*64;</p>
<p>data8=((data8/5)-1)*128;</p>
<p>ir_data=data8+data7+data6+data5+data4+data3+data2+data1;</p>
<p>&#8230;</p>
<p>}      };</p>
<p>}</p>
<p>Silahkan order ke <a href="http://toko-elektronika.com/index.php?h=9&amp;UID=20110717060801202.152.194.164&amp;ItemID=1801">sini</a> atau  ke <a href="mailto:widodo@widodo.com">widodo@widodo.com</a> , HP : 081410043883/08569887384  untuk paket demo alat ini seharga 3.5 juta lengkap dengan kode demo.</p>
]]></content:encoded>
			<wfw:commentRss>http://widodo.com/elektronika/kendali-alat-dengan-remote-tv/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The lyrics for our Family&#8217;s enlightment</title>
		<link>http://widodo.com/uncategorized/the-lyrics-for-our-enlightment/</link>
		<comments>http://widodo.com/uncategorized/the-lyrics-for-our-enlightment/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 14:21:20 +0000</pubDate>
		<dc:creator>widodo</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://widodo.com/?p=464</guid>
		<description><![CDATA[This song so beautiful and makes me enlighted  . The happiness of our family is our concern.   The reality is that family happiness is not that hard to realize even in today’s stressful times. It just requires that you refocus your life by stop trying to live and start living and simplify your live   [...]]]></description>
			<content:encoded><![CDATA[<p>This song so beautiful and makes me enlighted <img src='http://widodo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . The happiness of our family is our concern.   The reality is that family happiness is not that hard to realize even in today’s stressful times. It just requires that you refocus your life by <strong>stop trying to live and start living and simplify your live  <img src='http://widodo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</strong></p>
<p><strong> <img class="alignnone" src="http://widodo.com/wp-content/uploads/2011/03/41668_100000382099865_8498_n.jpg" alt="" width="200" height="300" /><br />
</strong></p>
<p><strong>The greatest love of all </strong></p>
<p>by : George Benson</p>
<p>I believe the children are our are future<br />
Teach them well and let them lead the way<br />
Show them all the beauty they possess inside<br />
Give them a sense of pride to make it easier<br />
Let the children&#8217;s laughter remind us how we used to be<br />
Everybody searching for a hero<br />
People need someone to look up to<br />
I never found anyone who fulfill my needs<br />
A lonely place to be<br />
So I learned to depend on me</p>
<p>Chorus:<br />
I decided long ago, never to walk in anyone&#8217;s shadows<br />
If I fail, if I succeed<br />
At least I&#8217;ll live as I believe<br />
No matter what they take from me<br />
They can&#8217;t take away my dignity<br />
Because the greatest love of all<br />
Is happening to me<br />
I found the greatest love of all<br />
Inside of me<br />
The greatest love of all<br />
Is easy to achieve<br />
Learning to love yourself<br />
It is the greatest love of all</p>
<p>I believe the children are our future<br />
Teach them well and let them lead the way<br />
Show them all the beauty they possess inside<br />
Give them a sense of pride to make it easier<br />
Let the children&#8217;s laughter remind us how we used to be</p>
<p>Chorus</p>
<p>And if by chance, that special place<br />
That you&#8217;ve been dreaming of<br />
Leads you to a lonely place<br />
Find your strength in love</p>
]]></content:encoded>
			<wfw:commentRss>http://widodo.com/uncategorized/the-lyrics-for-our-enlightment/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

