annwar
Newbie level 6
- Joined
- Feb 25, 2011
- Messages
- 14
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- Sabah, Malaysia
- Activity points
- 1,495
this is my circuit n my coding.. for the program... but... im not complete with the program.. in the RF function part.... can u please correct me.. if im wrong... n HELP me with the coding in the RF function part... im having a little problem.. using mikroc compiler.. THANKS..
//-------------------------RF _ TRANSMITTER TX-------------------------//
//-------------------------------------------------------------------------//
// 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
// Keypad module connections
char keypadPort at PORTD;
// End Keypad module connections
unsigned short kp, oldstate[17], i;
unsigned long data delay(void);
void InitLCD(void);
char txt[6];
//===================================================================================
// define
//===================================================================================
#define send_button RA3
#define display PORTB
#define SYNC_DATA 0x00
#define HEADER 0xaa
//#define buzzer RB2
initMain(); //Main initialization
void initMain() //main initialization of SFR registers
{
INTCON = 0x00; //turn off interrupts
ADRESH = 0x00;
ADRESL = 0x00;
ADCON1 = 0x0F; //all inputs are digital
ADCON0 = 0x00;
TRISD = 0xFF; //PORTD is input
TRISB = 0x00;
PORTB = 0x00;
PORTD = 0x00;
}
Keypad_Init(); //Initialize Keyboard
Lcd_Init(); //Initialize LCD
Lcd_Cmd(_LCD_CLEAR) ; // Clear display
char txt1[] = "WELCOME TO";
char txt2[] = "LECTUREROOM";
char txt3[] = "PLEASE ENTER";
char txt4[] = "NUMBER =";
char txt5[] = "(1)SENSEI ZAID ";
char txt6[] = "(2)SENSEISUHANA ";
char txt7[] = "(3)SENSEI MASRI ";
char txt8[] = "(4)SENSEI SAM";
char txt9[] = "(5)SENSEI ZUL";
char txt10[] = "(6)SENSEI ANWAR";
//-------------------------------------------------------------------------//
//-------------------------------------------------------------------------//
void Move_Delay()
{ // Function used for text moving
Delay_ms(1000); // You can change the moving speed here
}
void main()
{
TRISB = 0;
PORTB = 0xFF;
TRISB = 0xff;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
//-------------------------------------------------------------------------//
//-------------------------------------------------------------------------//
Lcd_Out(1,3,txt1); // Write text in first row
Lcd_Out(2,3,txt2); // Write text in second row
Delay_ms(1000);
// Moving text
for(i=0; i<3; i++) { // Move text to the right 4 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
// Endless loop
for(i=0; i<4; i++)
{
Lcd_Cmd(_LCD_SHIFT_LEFT); // Move text to the left 4 times
Move_Delay();
}
for(i=0; i<2; i++)
{
Lcd_Cmd(_LCD_SHIFT_RIGHT); // Move text to the right 4 times
Move_Delay();
}
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Out(1,1,txt5); // Write text in 5th row
Lcd_Out(2,1,txt6);
Delay_ms(6000);
Lcd_Cmd(_LCD_CLEAR); // Clear display // Write text in 6th row
Lcd_Out(1,1,txt7); // Write text in 7th row
Lcd_Out(2,1,txt8);
Delay_ms(6000);
Lcd_Cmd(_LCD_CLEAR); // Clear display // Write text in 8th row
Lcd_Out(1,1,txt9);
Lcd_Out(2,1,txt10);
Delay_ms(6000);
Lcd_Cmd(_LCD_CLEAR); // Clear display // Write text in 9th row
/*
Lcd_Out(1, 1, "Enter Digit: "); //
*/
// Clear display // Write text in 9th row
Lcd_Out(1, 3, "Please Wait..."); //
Lcd_Out(2, 3, ".........");
for(i=0; i<2; i++)
{
Lcd_Cmd(_LCD_SHIFT_LEFT); // Move text to the left 4 times
Move_Delay();
}
for(i=0; i<6; i++)
{
Lcd_Cmd(_LCD_SHIFT_RIGHT); // Move text to the right 4 times
Move_Delay();
}
for(i=0; i<3; i++)
{
Lcd_Cmd(_LCD_SHIFT_LEFT); // Move text to the left 4 times
Move_Delay();
}
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Enter Digit = "); //
Lcd_Out(2, 1, "= "); //
do
{ //infinite loop
/**/
kp = 0;
while (!kp)
{ //Wait for key to be pressed and released
kp = Keypad_Key_Click(); //There is a Click function in new library
Delay_ms(1); //wait a bit
}
/*
if('1')
{
Lcd_Out(2, 5, "SENSEI ZAID");
}
if('2')
{
Lcd_Out(2, 5, "SENSEI SUHANA");
}
if('3')
{
Lcd_Out(2, 5, "SENSEI MASRI");
}
if('4')
{
Lcd_Out(2, 5, "SENSEI SAM");
}
if('5')
{
Lcd_Out(2, 5, "SENSEI ZUL");
}
if('6')
{
Lcd_Out(2, 5, "SENSEI ZUL");
}
*/
for(i=0; i<12; i++)
oldstate = 0; //reset to 0 keypress counter
switch (kp)
{ // Prepare value for output
case 1: kp = '1'; break;
case 2: kp = '2'; break;
case 3: kp = '3'; break;
case 5: kp = '4'; break;
case 6: kp = '5'; break;
case 7: kp = '6'; break;
case 9: kp = '7'; break;
case 10: kp = '8'; break;
case 11: kp = '9'; break;
case 13: kp = '*'; break;
case 14: kp = '0'; break;
case 15: kp = '#'; break;
default: kp = 0;
}
/*
*/
Lcd_Chr(1, 14, kp); // Print KEY on LCD
Lcd_Out(2, 10, txt); // Print number of pressings
}
while (1);
//~!
}
//-------------------------------------------------------------------------//
//-------------------------------------------------------------------------//
/*
// MAIN RF TX TRANSMITTER
//===================================================================================
// define
//===================================================================================
#define send_button RA3
#define display PORTB
//===================================================================================
// function prototype
//===================================================================================
unsigned char data uart_send(void);
unsigned char data send_packet(void);
//===================================================================================
// functions
//===================================================================================
unsigned char data uart_send(void)
{
while(TXIF==0); //only send the new data after
TXREG = data ; //the previous data finish sent
}
unsigned char data send_packet(void)
{
unsigned char i; // Buffer for the data in one packet.
unsigned char buffer[3];
// Byte 0 is the header.
buffer[1] = data; // Byte 1 is the data.
buffer[2] = (unsigned char)(HEADER + data); // Byte 2 is the checksum.
for (i = 0; i < 7; i++) uart_send(SYNC_DATA); // Clocking for a while before sending the data so that the Tx and Rx are in sync.
for (i = 0; i < 3; i++) uart_send(buffer); // Transmit the packet using UART.
}
*/
---------- Post added at 19:33 ---------- Previous post was at 19:28 ----------
the program for the RF function.. for transmit n recieve is not complete.. this is the transmit part only.. for the recieve.. part.. i donno how to.. deal with it..
this prograam.. is funtion as.. when.. keypad pressed.. example.. no. 4... it will be send.. to the reciever.. n shown on the LCD.. by pushing the send button.. RA3..
im trying to send a couple of number.. to reciever.. or data... text.. to the reciever.. CAN U HELP ME>>
a simple coding.. for RF.. to send the desired data.....
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?