-->

LED Blinking program by using Mikro C -

By
LED Blinking program  by using Mikro  (PIC 16F877)

void main() {
TRISB = 0; //Makes PORTB0 or RB0 Output Pin

while(1) //Infinite Loop
{
PORTB = 0x55; //LED ON
Delay_ms(1000); //1 Second Delay
PORTB = 0xAA; //LED OFF
Delay_ms(1000); //1 Second Delay
}
}

LED Blinking program by using Mikro C -

By
LED Blinking program  by using Mikro  (PIC 16F877)

void main() {
 TRISB = 0; //Makes PORTB0 or RB0 Output Pin

  while(1) //Infinite Loop
  {
    PORTB = 0x55; //LED ON
    Delay_ms(1000); //1 Second Delay
    PORTB = 0xAA; //LED OFF
    Delay_ms(1000); //1 Second Delay
  }
}

LED Blinking program by Using Atmega32 - Atmel Studio 6

By
LED Blinking program by Using Atmega32 - Atmel Studio 6 

#ifndef F_CPU                    // defining clock speed of the processor
#define F_CPU 16000000UL // 16 MHz clock speed
#endif

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
DDRC = 0xFF; //Nakes PORTC as Output
while(1) //infinite loop
{
PORTC = 0xFF; //Turns ON All LEDs
_delay_ms(30); //1 second delay
PORTC= 0x00; //Turns OFF All LEDs
_delay_ms(30); //1 second delay
}
}


LED Blinking By using 8051 in Keil IDE
LED Blinking using PIC 16f877a

LED Blinking program by Using Atmega32 - Atmel Studio 6

By
LED Blinking program by Using Atmega32 - Atmel Studio 6 

#ifndef F_CPU                    // defining clock speed of the processor
#define F_CPU 16000000UL         // 16 MHz clock speed
#endif

#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
 DDRC = 0xFF;                //Nakes PORTC as Output
 while(1) //infinite loop
 {
  PORTC = 0xFF;      //Turns ON All LEDs
  _delay_ms(30);    //1 second delay
  PORTC= 0x00;      //Turns OFF All LEDs
  _delay_ms(30);   //1 second delay
 }
}


LED Blinking By using 8051 in Keil IDE
LED Blinking using PIC 16f877a

LED Blinking Program by using PIC 16f877a MPLAB X .

By
 compiler - sdcc ,XC8.
 


#define _XTAL_FREQ 8000000 // setting the crystal frequency 

#include <xc.h> // Header file inclusion ,to add function like _delay_ms()

#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config CP = OFF // FLASH Program Memory Code Protection bits (Code protection off)
#pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = ON // Low Voltage In-Circuit Serial Programming Enable bit (RB3/PGM pin has PGM function; low-voltage programming enabled)
#pragma config CPD = OFF // Data EE Memory Code Protection (Code Protection off)
#pragma config WRT = ON // FLASH Program Memory Write Enable (Unprotected program memory may be written to by EECON control)



int main()
{
TRISB0 = 0; //RB0 as Output PIN
while(1) // endless loop
{
RB0 = 1; // LED ON
__delay_ms(1000); // 1 Second Delay
RB0 = 0; // LED OFF
__delay_ms(1000); // 1 Second Delay
}
return 0;
}




LED Blinking By using 8051 in Keil IDE
/led-blinking-program-by-using-atmega32

LED Blinking Program by using PIC 16f877a MPLAB X .

By
 compiler - sdcc ,XC8.
 


#define _XTAL_FREQ 8000000 // setting the crystal frequency 

#include <xc.h>           // Header file inclusion ,to add function like _delay_ms() 

#pragma config PWRTE = OFF      // Power-up Timer Enable bit (PWRT disabled)
#pragma config CP = OFF         // FLASH Program Memory Code Protection bits (Code protection off)
#pragma config BOREN = ON       // Brown-out Reset Enable bit (BOR enabled)
#pragma config LVP = ON         // Low Voltage In-Circuit Serial Programming Enable bit (RB3/PGM pin has PGM function; low-voltage programming enabled)
#pragma config CPD = OFF        // Data EE Memory Code Protection (Code Protection off)
#pragma config WRT = ON         // FLASH Program Memory Write Enable (Unprotected program memory may be written to by EECON control)



int main()
{
  TRISB0 = 0; //RB0 as Output PIN
  while(1)    // endless loop
  {
    RB0 = 1;  // LED ON
    __delay_ms(1000); // 1 Second Delay
    RB0 = 0;  // LED OFF
    __delay_ms(1000); // 1 Second Delay
  }
  return 0;
}




LED Blinking By using 8051 in Keil IDE
/led-blinking-program-by-using-atmega32

LED Blinking By using 8051 in Keil IDE

By
sbit LED1 = P2^0;  // P2.0 of the pin name cahnged to LED1
void delay(); // a delayis used to give some delay in between turn ON and OFF

void main()
{
while(1)
{

LED1 = 0;

delay();

LED1 = 1 ;
delay();

}
}

void delay()
{
int j;

for(j=0; j<500; j++)
;
}

LED Blinking By using 8051 in Keil IDE

By
sbit LED1 = P2^0;  // P2.0 of the pin name cahnged to LED1
void delay();    // a delayis used  to give some delay in between turn ON  and OFF  

void main()
{
  while(1)
  {
  
 LED1 = 0;
 
 delay();

 LED1 = 1 ;
 delay();
 
   }
}

 void delay()
 {
   int j;
     
    for(j=0; j<500; j++)
    ;
 }

Transport Layer

By
Next Page
  TCP/IP layers 


  • recall the 5-layer model above
  • the network interface layer is often called the link layer
  • we use the generic term packet for each block of data transmitted
  • recall that each layer adds its own header, so nature of "packet" varies
  • so in fact the following terms are usually used for "packets" at each layer
    • frames at the link layer
    • datagrams at the internet layer
    • segments at the transport layer
  • we focus on the transport layer in this section

Transport Layer

By
Next Page
  TCP/IP layers 


  • recall the 5-layer model above
  • the network interface layer is often called the link layer
  • we use the generic term packet for each block of data transmitted
  • recall that each layer adds its own header, so nature of "packet" varies
  • so in fact the following terms are usually used for "packets" at each layer
    • frames at the link layer
    • datagrams at the internet layer
    • segments at the transport layer
  • we focus on the transport layer in this section

LCD 4-BIT MODE with 8051

By
LCD 4-BIT MODE with 8051

TO know the Basic of LCD go to the previous post click here .
There are many reasons why sometime we prefer to use LCD in 4-bit mode instead of 8-bit. One basic reason is lesser number of pins are needed to interface LCD.

In 4-bit mode the data is sent in nibbles, first we send the higher nibble and then the lower nibble. To enable the 4-bit mode of LCD, we need to follow special sequence of initialization that tells the LCD controller that user has selected 4-bit mode of operation. We call this special sequence as resetting the LCD. Following is the reset sequence of LCD.
  • Wait for abour 20mS
  • Send the first init value (0x30)
  • Wait for about 10mS
  • Send second init value (0x30)
  • Wait for about 1mS
  • Send third init value (0x30)
  • Wait for 1mS
  • Select bus width(0x30 - for 8-bit and 0x20 for 4-bit)
  • Wait for 1mS

The busy flag will only be valid after the above reset sequence. Usually we do not use busy flag in 4-bit mode as we have to write code for reading two nibbles from the LCD. Instead we simply put a certain ammount of delay usually 300 to 600uS. This delay might vary depending on the LCD you are using, as you might have a different crystal frequency on which LCD controller is running. So it actually depends on the LCD MODULE you are using. So if you feel any problem running the LCD, simply try to increase the delay. This usually works. For me about 400uS works perfect.
LCD connections in 4-bit Mode




Above is the connection diagram of LCD in 4-bit mode, where we only need 6 pins to interface an LCD. D4-D7 are the data pins connection and Enable and Register select are for LCD control pins. We are not using Read/Write (RW) Pin of the LCD, as we are only writing on the LCD so we have made it grounded permanently. If you want to use it.. then you may connect it on your controller but that will only increase another pin and does not make any big difference. Potentiometer RV1 is used to control the LCD contrast. The unwanted data pins of LCD i.e. D0-D3 are connected to ground.
LCD connections in 4-bit Mode
We will now look into the common steps to send data/command to LCD when working in 4-bit mode. As i already explained in 4-bit mode data is sent nibble by nibble, first we send higher nibble and then lower nibble. This means in both command and data sending function we need to saperate the higher 4-bits and lower 4-bits.


The common steps are:
  • Mask lower 4-bits
  • Send to the LCD port
  • Send enable signal
  • Mask higher 4-bits
  • Send to LCD port
  • Send enable signal
Program
 lcd.c file 

#include<reg51.h>

#include<stdio.h>   

#define LCDPORT P2

sbit RS = LCDPORT ^ 0;
sbit RW = LCDPORT ^ 1;
sbit E = LCDPORT ^ 2;
#include "lcd.h"     
void main()
{
lcd_init();
lcd_com(15);
lcd_puts("test");
lcd_com(0XC0);
lcd_puts("World");
while (1);
}

  ---------------------------------------------------------------------------------------------------------------------------


lcd.h file .




bit status = 0;
#define lcd_delay 400 
void delay(unsigned int j)
{
    unsigned int i = 0;
    for (; i < j; i++);
} 
void_lcd_init_write(unsigned char a)
{
    RS = 0;
    RW = 0;
    LCDPORT = a;
    E = 1;
    delay(lcd_delay);
    E = 0;
} 
void lcd_com(unsigned char a)
{
    unsigned char temp;
    if (status) {
     status = 0;
     gotonext;
    }
    RS = 0;
  next:
  RW = 0;
    temp = a;
    temp &= 0xf0;
    LCDPORT &= 0x0f;
    LCDPORT |= temp;
    E = 1;
    delay(lcd_delay);
    E = 0;
    temp = a << 4;
    temp &= 0xf0;
    LCDPORT &= 0x0f;
    LCDPORT |= temp;
    E = 1;
    delay(lcd_delay);
    E = 0;
}

void lcd_data(unsigned char a)
{
    status = 1;
    RS = 1;
    lcd_com(a);
}



void lcd_init(void)
{
    delay(lcd_delay);
    lcd_init_write(0x30);
    delay(lcd_delay);
    lcd_init_write(0x30);
    delay(lcd_delay);
    lcd_init_write(0x30);
    delay(lcd_delay);
    lcd_init_write(0x20);
    delay(lcd_delay);
    lcd_com(0x28);
    delay(lcd_delay);
    lcd_com(4);
    delay(lcd_delay);
    lcd_com(0x85);
    delay(lcd_delay);
    lcd_com(6);
    delay(lcd_delay);
    lcd_com(1);
    delay(lcd_delay);
}


void lcd_puts(char *aaa)
{
    unsigned int i = 0;
    for (; aaa[i] != 0; i++)
     lcd_data(aaa[i]);
}

Download here the Proteus and Keil File Click Here






 
 
Till now whatever we discussed in the previous part of ths LCD tutorial, we were dealing with 8-bit mode. Now we are going to learn how to use LCD in 4-bit mode. There are many reasons why sometime we prefer to use LCD in 4-bit mode instead of 8-bit. One basic reason is lesser number of pins are needed to interface LCD.

In 4-bit mode the data is sent in nibbles, first we send the higher nibble and then the lower nibble. To enable the 4-bit mode of LCD, we need to follow special sequence of initialization that tells the LCD controller that user has selected 4-bit mode of operation. We call this special sequence as resetting the LCD. Following is the reset sequence of LCD.
  1. Wait for abour 20mS
  2. Send the first init value (0x30)
  3. Wait for about 10mS
  4. Send second init value (0x30)
  5. Wait for about 1mS
  6. Send third init value (0x30)
  7. Wait for 1mS
  8. Select bus width (0x30 - for 8-bit and 0x20 for 4-bit)
  9. Wait for 1mS
- See more at: http://www.8051projects.net/lcd-interfacing/lcd-4-bit.php#sthash.MwfMgDYA.dpuf
Till now whatever we discussed in the previous part of ths LCD tutorial, we were dealing with 8-bit mode. Now we are going to learn how to use LCD in 4-bit mode. There are many reasons why sometime we prefer to use LCD in 4-bit mode instead of 8-bit. One basic reason is lesser number of pins are needed to interface LCD.

In 4-bit mode the data is sent in nibbles, first we send the higher nibble and then the lower nibble. To enable the 4-bit mode of LCD, we need to follow special sequence of initialization that tells the LCD controller that user has selected 4-bit mode of operation. We call this special sequence as resetting the LCD. Following is the reset sequence of LCD.
  1. Wait for abour 20mS
  2. Send the first init value (0x30)
  3. Wait for about 10mS
  4. Send second init value (0x30)
  5. Wait for about 1mS
  6. Send third init value (0x30)
  7. Wait for 1mS
  8. Select bus width (0x30 - for 8-bit and 0x20 for 4-bit)
  9. Wait for 1mS
- See more at: http://www.8051projects.net/lcd-interfacing/lcd-4-bit.php#sthash.MwfMgDYA.dpuf

More Posts

gElectron. Powered by Blogger.

Contributors

16x2 LCD Interfacing with STM32,STM32F103C6

 16x2 LCD  Interfacing with STM32,STM32F103C6 lcd_init(); LCD_LINE1; lcd_String(" GeElectron"); LCD_LINE2; lc...

Contact Form

Name

Email *

Message *

Contact us

Name

Email *

Message *

Follow Us

https://www.facebook.com/gElectron-393939667321867/ FBbox/https://www.facebook.com/IVYthemes

Comments

[blogger]

MKRdezign

Test

Latest

[recent][newsticker]

Technology

Top Ads

RECENT COMMENTS

Subscribe Via Email

Subscribe to our newsletter to get the latest updates to your inbox. ;-)


Your email address is safe with us!

RECENT COMMENTS