Let the future tell the truth and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I really worked, is mine. (Nikola Tesla)

23/08/2010


●Displaying Constant Scripts on 2x16 LCD

Here is the program written by using CCS C.



#include <16f628.h>
#fuses NOPROTECT, NOWDT, NOLVP, NOMCLR, INTRC_IO
#use delay(clock=4M)
#include //It is essential for using LCD in our program

void main(){

lcd_init(); //Must be called before any other function
while(1){
lcd_gotoxy(1,2); //To set write position on LCD
lcd_putc("Sezgin Secil"); //Displaying script on the next position of the LCD
}
}



Note: For using LCD in our designs, we should use lcd.c file. It is used for both Port B and D. So, if we want to use it for Port B, we need a modification in the lcd.c file:
Find LCD.C file in drivers, open it, find the line that consists of "//define use_portb_lcd TRUE" and change that as "define use_portb_lcd TRUE". All you need to do is removing the the double slash at the beginning of the command.



15/08/2010


●Counting from 9 to 0 on 7-Segment Display

Here is the program written by using CCS C.



#include <16f628.h>
#fuses NOPROTECT, NOWDT, NOLVP, NOMCLR, INTRC_IO //Adding internal oscillator with INTRC_IO and MCLR makes possible to reset but with NOMCLR there is no need to connect anything that pin
#use delay(clock=4M) //To define the delay time correctly

void main(){
char series[]={63,6,91,79,102,109,125,7,127,111}; //Defining the decimal values of total logic values on 7-segment display
char x=9; //To start the loop from 9nd value
while(1){
do{
output_b(series[x]); //To show the desired value on 7-segment display
delay_ms(250); //Delay for observation
x--;
}while((x+1)); //To end the loop
x=9;
}
}



●Flashing LED Controlled by a Button

Here is the program written by using CCS C.


#include <16f628.h>
#fuses NOPROTECT, NOWDT, NOLVP, NOMCLR INTRC_IO //Adding internal oscillator with INTRC_IO and MCLR makes possible to reset but with NOMCLR there is no need to connect anything that pin
#use delay(clock=4M) //To define the delay time correctly

void main(){
while(1){ // For an endless loop
if(!input(pin_a0)) //Checking the input of the first pin of port A
output_high(pin_b0); //If input is low, LED flashes
else output_low(pin_b0); //If input is high, LED doesn't flash
}
}


ShareThis