24 September, 2011 (20:35) | Electronics, PIC microcontroller | By: xenon ark
This is a very easy tutorial to connect a PIC with an LCD. The program is written by mikroC PRO 4.60 Check the LCD library from the library manager before compiling the program.
the program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| // LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
void main(){
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,2,"PIC16F877A LCD"); // Write text in first row
Lcd_Out(2,3,"control7.net"); // Write text in second row
} |
The Schematic:

Demo run:

mikroC download
Download mikroC from here.
Tags: LCD, PIC mocrocontroller, PIC tutorial, PIC16F877a
Comments: -
19 April, 2011 (03:58) | AVR Microcontroller, Electronics | By: xenon ark
There are several character LCD available in market 16×2, 16×4, 20×2 etc. these are very useful and pretty cheap also. This is a small program to demonstrate how interfacing LCD with AVR. I have used Atmega8 to run the program.
This is the schematic:

Pinout chart:

LCD in action:

Source code:
Download source codes. (VAR studio 4 required)
Tags: AVR, AVR GCC, LCD
Comments: 1
30 March, 2011 (23:40) | AVR Microcontroller, Electronics | By: xenon ark
This small tutorial will show how to read signal from a push button and on/off two led by the input signal. I have used Atmega48 to write and test the program but you can use any AVR which supports AVR GCC.
Before pressing the push button it is like:

After pressing the push button:

Sketch of the schematic:

Here is the program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
| #include <avr/io.h>
#include <stdio.h>
//Method to read pin status
uint8_t GetKeyStatus(uint8_t key)
{
return (!(PINB & (1<<key)));
}
void main()
{
DDRB = 0b00000111; //set B0, B1 and B2 as output
while(1)
{
if(GetKeyStatus(0)) //reading B0 status
{
PORTB = 0b00000010; //set B1 as HIGH
}
else
{
PORTB = 0b00000100; //set B2 as HIGH
}
}
} |
We can read PB0. When the button is not pressed, PB1 is high otherwise PB2 is high.
Tags: AVR, AVR GCC, I/O, Input, LED, Output, Push Button
Comments: 3
Recent Comments