pigbaobao
Member level 2
Hi, I am proceeding a project which is a wireless data transmission using RF module. ![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
I was done a source code (Mikro-c compiler) and i dun know where the problem is. 8O
I am newbie in c-programming and i sincerely ask from you all suggestion or any idea about my project. :|
Below is my simple source code for transmission side and receiver side. Any pro please help me check whether the program is correct or where need to edit. Thank for help, i very appreciate it...^^ :lol:![Stick out tongue :p :p](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Transmission side,
#include <stdio.h>
#define click_button RA1
#define send_button RA2
char string;
void main() {
unsigned int num;
char string1[]= "Welcome";
char string2[]= "Final Year Project";
char string3[]= "Wireless Data Transmission";
char string4[]= "Thank You";
ANCON1 = 0; // Configure AN pins as digital
TRISA = 0b11111111; //configure PORTA as input
TRISB = 0b00000000; //configure PORTB as output
PORTC = 1; //LED ON
TRISC = 1;
Delay_ms(1000);
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
num=0;
while(click_button == 1)
{
num++;
if(num > 3)
num=0;
Delay_ms(1000);
}
while(send_button == 1)
{
UART1_Write(string[num]);
Delay_ms(1000);
}
}
Receiver side,
#include <stdio.h>
// LCD module connections
sbit LCD_RS at RD4_bit;
sbit LCD_EN at RD5_bit;
sbit LCD_D4 at RD0_bit;
sbit LCD_D5 at RD1_bit;
sbit LCD_D6 at RD2_bit;
sbit LCD_D7 at RD3_bit;
sbit LCD_RS_Direction at TRISD4_bit;
sbit LCD_EN_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD0_bit;
sbit LCD_D5_Direction at TRISD1_bit;
sbit LCD_D6_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD3_bit;
// End LCD module connections
char string[];
void Move_Delay() { // Function used for text moving
Delay_ms(500); // You can change the moving speed here
}
void main(){
PORTC = 1; //LED
TRISC = 1;
TRISD = 0;
PORTD = 0xFF;
TRISD = 0xff;
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
UART1_Init(9600);
while (UART1_Data_Ready() == 1) {
string = UART1_Read();
Lcd_Out(1,6,string); // Write text in first row
Lcd_Out(2,6,string); // Write text in second row
Delay_ms(8000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
// Moving text
for(i=0; i<4; i++) { // Move text to the right 4 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
while(1) { // Endless loop
for(i=0; i<8; i++) { // Move text to the left 7 times
Lcd_Cmd(_LCD_SHIFT_LEFT);
Move_Delay();
}
for(i=0; i<8; i++) { // Move text to the right 7 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
}
}
}
I was done a source code (Mikro-c compiler) and i dun know where the problem is. 8O
I am newbie in c-programming and i sincerely ask from you all suggestion or any idea about my project. :|
Below is my simple source code for transmission side and receiver side. Any pro please help me check whether the program is correct or where need to edit. Thank for help, i very appreciate it...^^ :lol:
Transmission side,
#include <stdio.h>
#define click_button RA1
#define send_button RA2
char string;
void main() {
unsigned int num;
char string1[]= "Welcome";
char string2[]= "Final Year Project";
char string3[]= "Wireless Data Transmission";
char string4[]= "Thank You";
ANCON1 = 0; // Configure AN pins as digital
TRISA = 0b11111111; //configure PORTA as input
TRISB = 0b00000000; //configure PORTB as output
PORTC = 1; //LED ON
TRISC = 1;
Delay_ms(1000);
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
num=0;
while(click_button == 1)
{
num++;
if(num > 3)
num=0;
Delay_ms(1000);
}
while(send_button == 1)
{
UART1_Write(string[num]);
Delay_ms(1000);
}
}
Receiver side,
#include <stdio.h>
// LCD module connections
sbit LCD_RS at RD4_bit;
sbit LCD_EN at RD5_bit;
sbit LCD_D4 at RD0_bit;
sbit LCD_D5 at RD1_bit;
sbit LCD_D6 at RD2_bit;
sbit LCD_D7 at RD3_bit;
sbit LCD_RS_Direction at TRISD4_bit;
sbit LCD_EN_Direction at TRISD5_bit;
sbit LCD_D4_Direction at TRISD0_bit;
sbit LCD_D5_Direction at TRISD1_bit;
sbit LCD_D6_Direction at TRISD2_bit;
sbit LCD_D7_Direction at TRISD3_bit;
// End LCD module connections
char string[];
void Move_Delay() { // Function used for text moving
Delay_ms(500); // You can change the moving speed here
}
void main(){
PORTC = 1; //LED
TRISC = 1;
TRISD = 0;
PORTD = 0xFF;
TRISD = 0xff;
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
UART1_Init(9600);
while (UART1_Data_Ready() == 1) {
string = UART1_Read();
Lcd_Out(1,6,string); // Write text in first row
Lcd_Out(2,6,string); // Write text in second row
Delay_ms(8000);
Lcd_Cmd(_LCD_CLEAR); // Clear display
// Moving text
for(i=0; i<4; i++) { // Move text to the right 4 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
while(1) { // Endless loop
for(i=0; i<8; i++) { // Move text to the left 7 times
Lcd_Cmd(_LCD_SHIFT_LEFT);
Move_Delay();
}
for(i=0; i<8; i++) { // Move text to the right 7 times
Lcd_Cmd(_LCD_SHIFT_RIGHT);
Move_Delay();
}
}
}
}