Discussion in "Project Help" started by    kira113    Aug 19, 2017.
Sat Aug 19 2017, 08:52 AM
#1
hello everyone
i write a simple program using c language for read analog value from adc0804 then convert that value to three decimal number and then display them on 3 seven_seg but when i compile the program using keil ide i got some error ( like 'multiple public definition ')
can anyone help me with it .
#include <REGX51.H>
sbit cs   = P3^7 ;
sbit WRIT	= P3^5 ;
sbit READ	= P3^6 ;
sbit inter= P3^4 ;
#define adc_port  P1 
#define seg_port  P0 

char ones,tens,hunds,digital_value,rfd;
int table[16]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,0x08,0x03,0x46,0x21,0x06,0x0e};
void conv();
void read_adc();
void delay_us(int);
void delay_ms(int);
void delay_sec( char);
void div23dig(char);
void disp ( char , char, char );
void main(){
							
							adc_port = 0xff	;		//init adc_Port as input
									P0 = 0X0			;//init p0 as output
									P3= 0x10		;	//init p3.4 as input
								while(1){
									
									
										conv();
										read_adc();
										div23dig(digital_value);
									  disp(ones,tens,hunds);
										delay_sec(1);
									 
										
												}
            }

void conv()
	{
		cs=0;
		WRIT=0;
		WRIT=1;
		cs=1;
		while(inter);
	}

void read_adc()
	{
			cs=0;
			READ=0;
			digital_value=adc_port;
			READ=1;
			cs=1;
  }

void delay_us( int us_count)
 {
    while(us_count!=0)
      {
         us_count--;
       }
   }
void delay_ms( int ms_count)
 {
        while(ms_count!=0)
         {
            delay_us(112);   /*delay_us is called to generate 1ms delay*/
             ms_count--;
            }
   }
void delay_sec( char sec_count)
 {

     while(sec_count!=0)
      {
         delay_ms(1000);    /*delay_ms is called to generate 1sec delay*/
         sec_count--;
        }
 }
void div23dig(char x )
 { 
		hunds= digital_value/100 ;
		rfd = digital_value%100 ;
	  tens = rfd/10;
		ones = rfd%10;
	
 }
void disp ( char x , char y ,char z )
 {  char i; 
		i = table[ones] ;
	  seg_port = i ;
	  P2=P2|1;
	  delay_ms(16);
		P2=P2&254;
	  i=table[tens];
	 seg_port=i;
	  P2=P2|2;
		delay_ms(16);
	   P2=P2&253;
		i= table[hunds];
	  seg_port=i;
	  P2=P2|4;
		delay_ms(16);
	  P2=P2&251;
 
 }



[ Edited Wed Aug 23 2017, 01:26 PM ]
Sun Aug 20 2017, 08:31 PM
#2

"when i compile the program using keil ide i got some error
( like 'multiple public definition ')"

When asking for help, giving the exact error message is important.
It is better to zip and post your full code,
as copying off the web page is not 100% successful.

I tried your code and got unused variables warnings for call
"void disp ( char x , char y ,char z )"
x,y and z are not used in the procedure.

I notice you declared it as
"void disp ( char , char, char );" without naming the variables.
That may be legal, but makes it harder to spot errors, as in the case above.


[ Edited Sun Aug 20 2017, 08:35 PM ]
Wed Aug 23 2017, 01:30 PM
#3
It will be easier to help if you can post the complete error message with line number. So we know which line is generating the error.
By the way, it's better to define "table" as const since you're not going to change it but just use it as a reference for digits.

Get Social

Information

Powered by e107 Forum System

Conversation

Tue Sep 19 2017, 08:36 PM
Ted
In a missing pulse detector using a 555 timer connected as a monostable vibrator with a PNP transistor,how does the positve input pulse turn on the PNP transistor?
Sun Sep 03 2017, 10:29 AM
martymarty
How do I connect an <NOKIA 1100 LCD > to an atmega328P ?
poojab51296
Sun Aug 20 2017, 06:23 AM
i am intending to interface sd card with STM32F4 and want to write a file in sd card using SPI protocol but using HAL only. Can anyone help me PLEASE!!!!
poojab51296
Sun Aug 20 2017, 06:22 AM
hello
rawat742
Fri Aug 18 2017, 07:37 AM
hi @ angel patel i will attach a file i hope it will be helpfull for you
ExperimenterUK
Mon Aug 14 2017, 05:57 PM
@ angel patel... just log in and post your problem
Mon Aug 14 2017, 09:45 AM
angel patel
hey any one help to make the led scrolling display
desuza6
Sat Jul 29 2017, 03:09 AM
I see the code for step motor h l 298 to rotate 45 degree, but all delay time, if I want to input sensor to h the pulses to stepmotor
rammichael
Thu Jul 27 2017, 08:05 AM
okay fine
ExperimenterUK
Wed Jul 26 2017, 03:51 PM
Please post questions in the forum, the chat box is for chat

Downloads

Comments

Cryterion
Fri Sep 22 2017, 05:42 PM
bask185
Fri Sep 22 2017, 12:18 PM
Theodon
Wed Sep 20 2017, 10:59 PM
komal_97
Wed Sep 20 2017, 12:18 PM
butt_butt
Fri Sep 08 2017, 02:58 PM
RKTJ
Fri Sep 08 2017, 01:55 PM
ahmed2016
Thu Sep 07 2017, 05:55 AM
Johnleonarduc
Sat Sep 02 2017, 01:48 AM

Online

Guests: 102, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 37892
Newest member: Cryterion
Forum Activity
bask185 Avatar
Posted By bask185
Mon Sep 25 2017, 06:38 AM
I might have a difficult question.At work we build...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Sep 21 2017, 01:33 AM
You could start with this tutorialhttp://www.8051p...
komal_97 Avatar
Posted By komal_97
Wed Sep 20 2017, 12:25 PM
hey, i want to interface 3 dc motors with the micr...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Sep 11 2017, 12:07 AM
The hardware for connecting to a PC or a modem is...
Suseethra Avatar
Posted By Suseethra
Sat Sep 09 2017, 09:43 AM
Hi,we are doing the same project(LED scrolling dis...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Aug 28 2017, 07:21 PM
First you have to decide which version of the 8051...
rawat742 Avatar
Posted By rawat742
Sat Aug 26 2017, 12:36 PM
Dear Sir, I want to purchase progra...
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Aug 25 2017, 08:22 PM
Debuggers and programmers are different things.Whi...
rawat742 Avatar
Posted By rawat742
Thu Aug 24 2017, 04:30 PM
Dear Sir, if I am not purchase debugger then how ...
poojab51296 Avatar
Posted By poojab51296
Thu Aug 24 2017, 06:27 AM
I am using STM32 cube MX and Atollic truestudio so...