RSS

TINY DEW SENSOR












                                                 

DEW (condensed moisture) adversely affects the normal performance of sensitive electronic devices. A low-cost circuit described here can be used to switch off any gadget automatically in case of excessive humidity. At the heart of the circuit is an inexpensive (resistor type) dew sensor element. Although dew sensor elements are widely used in video cassette players and recorders, these may not be easily available in local market. However, the same can be procured from authorised service centres of reputed companies. The author used the dew sensor for FUNAI VCP model No. V.I.P. 3000A (Part No: 6808-08-04, reference no. 336) in his prototype. In practice, it is observed that all dew sensors available for video application possess the same electrical characteristics irrespective of their physical shape/size, and hence are interchangeable and can be used in this project. The circuit is basically a switching type circuit made with the help of a popular dual op-amp IC LM358N which is configured here as a comparator. (Note that only one half of the IC is used here.) Under normal conditions, resistance of the dew sensor is low (1 kilo-ohm or so) and thus the voltage at its non-inverting terminal (pin 3) is low compared to that at its inverting input (pin 2) terminal. The corresponding output of the comparator (at pin 1) is accordingly low and thus nothing happens in the circuit. When humidity exceeds 80 per cent, the sensor resistance increases rapidly. As a result, the non-inverting pin becomes more positive than the inverting pin. This pushes up the output of IC1 to a high level. As a consequence, the LED inside the opto-coupler is energised. At the same time LED1 provides a visual indication. The opto-coupler can be suitably interfaced to any electronic device for switching purpose. Circuit comprising diode D2, resistors R5 and R6 and capacitor C1 forms a low-voltage, low-current power supply unit. This simple arrangement obviates the requirement for a bulky and expensive step-down transformer.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

8 Common Programming Mistakes

Learning to program can be tough--just ask anyone who's done it! Fortunately, a lot of problems happen over and over again--I've put together 8 of the most common problems that you'll run into as a new programmer.



1. Undeclared Variables:

 

int main()
{
  cin>>x;
  cout<
 
"Huh? Why do I get an error?" 
 
Your compiler doesn't know what x means. You need to declare it as a variable.
 
 int main()
{
  int x;
  cin>>x;
  cout<
 
 
 

2. Uninitialized variables:

 

int count;
while(count<100)
{
  cout<
 
 
"Why doesn't my program enter the while loop?"
 
In C++ variables are not initialized to zero. In the above snippet 
of code, count could be any value in the range of int. It might, 
for example, be 586, and in that situation the while loop's condition 
would never be true. Perhaps the output of the program would be 
to print the numbers from -1000 to 99. In that case, once again, 
the variable was assigned a memory location with garbage data 
that happened to evaluate to -1000. 
 Remember to initialize your variables.  
 
 

3. Setting a variable to an uninitialized value:

 

int a, b;
int sum=a+b;
cout<<"Enter two numbers to add: ";
cin>>a;
cin>>b;
cout<<"The sum is: "<
 
"What's wrong with my program?" 
 
Often beginning programmers believe that variables work like equations - if you assign a variable to equal the result of an operation 
on several other variables that whenever those variables change (a and b in this example), the value of the variable will change. 
In C++ assignment does not work this way: it's a one shot deal. 
Once you assign a value to a variable, it's that value until you
reassign the values. In the example program, because a and b are 
not initialized, sum will equal an unknown random number, no matter what the user inputs.  

 To fix this error, move the addition step after the input line.

int a, b;
int sum;
cout<<"Enter two numbers to add: ";
cin>>b;
cin>>a;
sum=a+b;
cout<<"The sum is: "<
 
 

4. Using a single equal sign to check equality:

 

char x='Y';
while(x='Y')
{
  //...
  cout<<"Continue? (Y/N)";
  cin>>x;
}
 
 
"Why doesn't my loop ever end?" 
 
If you use a single equal sign to check equality, your program 
will instead assign the value on the right side of the expression 
to the variable on the left hand side, and the result of this 
statement is TRUE. Therefore, the loop will never end. Use '== '
to check for equality; furthermore, to avoid accidental assignment, 
put variables on the left hand side of the expression and you'll 
get a compiler error if you accidentally use a single equal sign 
as you can't assign a value to something that isn't a variable.
 
 
 
char x='Y';
while('Y'==x)
{
  //...
  cout<<"Continue? (Y/N)";
  cin>>x;
}
 
 

5. Undeclared Functions:

 

int main()
{
  menu();
}
void menu()
{
  //...
}
 
"Why do I get an error about menu being unknown?" 
 
The compiler doesn't know what menu() stands for until you've 
told it, and if you wait until after using it to tell it that 
there's a function named menu, it will get confused. Always remember 
to put either a prototype for the function or the entire definition 
of the function above the first time you use the function. 
void menu();
int main()
{
  menu();
}
void menu()
{
  ...
}
 

6. Extra Semicolons:

 

int x;
for(x=0; x<100; x++);
  cout<
 
"Why does it output 100?" 
 
You put in an extra semicolon. Remember, semicolons don't go after 
if statements, loops, or function definitions. If you put one 
in any of those places, your program will function improperly.
 
int x;
for(x=0; x<100; x++)
  cout<
 
 
 

7. Overstepping array boundaries:

 

int array[10];
//...
for(int x=1; x<=10; x++)
  cout<
 
"Why doesn't it output the correct values?" 
 
 
Arrays begin indexing at 0; they end indexing at length-1. For 
example, if you have a ten element array, the first element is 
at position zero and the last element is at position 9. 
 
int array[10];
//...
for(int x=0; x<10; x++)
  cout<
 

8. Misusing the && and || operators:

 

int value;
do
{
  //...
  value=10;
}while(!(value==10) || !(value==20))
 
"Huh? Even though value is 10 the program loops. Why?" 
 
 
Consider the only time the while loop condition could be false: 
both value==10 and value==20 would have to be true so that the 
negation of each would be false in order to make the || operation
return false. In fact, the statement given above is a tautology; it is always true that value is not equal to 10 or not equal to 
20 as it can't be both values at once. Yet, if the intention is for the program only to loop if value has neither the value of 
ten nor the value of 20, it is necessary to use && : !(value==10) && !(value==20), which reads much more nicely: "if value is not 
equal to 10 and value is not equal to 20", which means if value is some number other than ten or twenty (and therein is the mistake 
the programmer makes - he reads that it is when it is "this" or "that", when he forgets that the "other than" applies to the entire 
statement "ten or twenty" and not to the two terms - "ten", "twenty" - individually). A quick bit of boolean algebra will help you 
immensely: !(A || B) is the equivalent of !A && !B (Try it and see). The sentence "value is other than [ten or twenty]" (brackets 
added to show grouping) is translatable to !(value==10 || value==20), and when you distribute the !, it becomes !(value==10) && !(value==20).
 
 
The proper way to rewrite the program:
 
 
int value;
do
{
  //...
  value=10;
}while(!(value==10) && !(value==20))
 
 
 

 

  

 

  

 

 

  

 

 

 

  

 

  

 

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

Latest Mathematics suggestion for 2012 Madhyamik(10th)

Hurry!!!     Hurry!!!       Hurry!!!

Madhyamik exam or 10th exam (West Bengal Board, W.B.B.S.E) for year 2012 is not so far. Its coming.
Confusion with mathematics???
Don't worry . . .


Here is the suggestion for mathematics. Just download it. It will help you. (80-90% common.)
Lets download and solve the questions....


Link 1: Click here Or 
Link 2: Click here 


[ Note: The suggestion is free. Please don't use it for sale. If you satisfy with this . and anyone want to donate some money. call @ 9933714807 . ]



Best of luck for your exam.

or you can download the images from below.








  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

SEPERATING A STRING INTO TOKENS

There are many ways to split a line of text up into tokens. One simple example is to split up the words in a sentence. The following code shows how to do this using the strtok() function. Just beware that this function alters the original string, so if you need to use it again, make a copy before calling strtok().



#include
#include

#define DELIM " "
#define MAXWORD 80
#define MAXLEN 20

int main(void)
{
char words[MAXWORD][MAXLEN];
char buff[BUFSIZ];
int ntokens = 0;
int i;

printf("Enter a string: ");
fflush(stdout);

if (fgets(buff, sizeof buff, stdin) != NULL)
{
char *sep = strtok(buff, DELIM);

while (sep != NULL)
{
strcpy(words[ntokens++], sep);
sep = strtok(NULL, DELIM);
}
}

for (i = 0; i < ntokens; i++)
{
puts(words[i]);
}
return(0);
}
/** Output : Enter a string: this is a long line of text
this
is
a
long
line
of
text **/

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS