Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How can I beep every 00:00 ?

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Visit site
Activity points
9,442
Guys,

I created a clock using DS1307,
How can I beep it everytime it's reaching zero ?

I have created:
Code:
//turn on chime
			minute = num2str(ds1307_addr[1]);
			second = num2str(ds1307_addr[0]);
			
			if ((second =="00") && (minute =="00"))
			  {
				  beep_sound_2();
			  }

Any ideas ?
thanks
 

You can't compare a string like that, you have to check each character individually

Code:
if ((second[0] =='0') && (second[1] =='0') && (minute[0] =='0') && (minute[1] =='0'))
  {
  }

- - - Updated - - -

by the way "minute" and "second" represent the address of the first character of the array , the same as "&minute[0]" and "&second[0]"
 

I think the second and minute are integer or char variables they cant be a stiring because they are assigned in the above statement so
the exact code shd be

Code C - [expand]
1
2
3
if ((second == 0)  &&  (minute == 0))
  {
  }

 

like this ?
thanks

Code:
char ds1307_addr[7];
	//turn on chime
			minute = ds1307_addr[1];
			second = ds1307_addr[0];
			
			if ((second ==0) && (minute ==0))
			  {
				  beep_sound_2();
			  }
			
		}
 

I think the second and minute are integer or char variables they cant be a stiring because they are assigned in the above statement

That may be so but in the given code there is no definition of these variables and there is a num2str function, if that function doesn't return a string then why is it named like that?

Code:
minute = num2str(ds1307_addr[1]);
second = num2str(ds1307_addr[0]);
 

yeah but what are you going to do in beep sound function?? If you just enabled buzzer then It will beep continuously after match 00, so add a else case to make it reset...
or do the both in the beep sound function......

- - - Updated - - -

That may be so but in the given code there is no definition of these variables and there is a num2str function, if that function doesn't return a string then why is it named like that?

I didnt look on the function names but if it is a function which returns char pointer and second and minute are char pointers then surely it will be like element checking as you mentioned, but the code shown in #4 shd work fine...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top