Tuesday, August 25, 2015

Control your Home and Robot by Missed Call from Cell Phone


You can find lots of projects from internet about controlling things like light, fan, washing machine and your robot from remote location. There are several ways for controlling these remotely such as using DTMF signal from cell phone (required DTMF decoder cricuit), using Bluetooth (require bluetooth module), using Internet (require Internet server,WiFi module or Ethernet Shield and lots of programming) or RF transmitter and receiver (Seeed RF link kit). A microcontroller or Arduino board is common for all systems. 

I am introducing here a completely new and very easy way to control household appliances (light, fan, washing machine) and your robot from remote place by using cell phone. A very small component is required and very easy to made. 

When we call someone from our cell phone we hear several long beep tone from our phone. I will use these tone as a hint to control our thing.

Click here to see detail of Missed call Control Home and Robot

You can read it in Bangle from here

Monday, August 24, 2015

Bugs in Programming

Bugs in Programming
Bug’s is an unexpected defect, fault, flaw or imperfections. In programming jargon, “errors” are known as “bugs”. Debugging is the name that programmers give to the activity of locating and removing errors from programs (once the errors are known to exist, from testing the program).

Programming errors or bugs are fall into three categories.
i.                   Syntax or compilation errors
ii.                 Logical errors or Semantic errors
iii.              Run-time errors

Syntax Errors
Syntax errors are grammatical mistakes. These errors are the easiest to find because they are highlighted by the compiler. Error messages are given. These errors are caused by the failure of the programmer to use the correct grammatical rules of the language Syntax errors are detected, and displayed by the complier as it attempts to translate your program. If a program has a syntax error it cannot be translated, and the program will not be executed.

The compiler tries to highlight syntax errors where there seems to be a problem, however, it is not perfect and sometimes the compiler will indicate the next line of code as having the problem rather the line of code where the problem actually exists.
Forgetting to close the message to printf ( ) with a double quote, omitting the semicolon at the end of each C statement, incorrectly typing the letter O for the number zero (0), or vice versa are some common syntax errors made by all beginning C programmer.

Logical errors
These are the hardest errors to find as they do not halt the program. They arise from faulty thinking on behalf of the programmer. They can be very troublesome. These are mistakes in a program’s logic. Programs with logic errors will often compiled, execute and output result. However, at least some of the time the output will be incorrect. Error message will not appear in case of logic errors, this makes logic errors very difficult to locate and correct.

Run-Time errors
As the name suggests run-time errors occurs at run time when the user directs the computer to perform an illegal operation, e.g.:
      Dividing a number by zero
      Assigning a variable to the wrong type of variable

When a run-time error occurs, the computer stops executing the program, and displays a diagnostic message that indicates the line where the errors occurred. 

Introduction to C

Introduction to C
C is one of the most popular general-purpose programming languages. C language has been designed and developed by Dennis Ritchie at AT&T Bell Laboratories, USA, in 1972. Several important concepts of C are drawn from ‘Basic Combined Programming Language (BPCL)’ and ‘B’ language. Martin Richards developed BCPL in 1967. The impact of BCPL on C is observed indirectly through the language B, which was developed by Ken Thompson in 1970.  C has an extensive set of capabilities and is a true general-purpose programming language. As such, it can be used for creating simple, interactive programs or highly sophisticated and complex engineering and scientific programs, within the context of truly structured language.

Why Use C?
In today’s world of computer programming, there are many high-level languages to choose from, such as C, C++, Java, Python and Ruby. These are all excellent languages suited for most programming task. Even so, there are several reasons why C is at the top of the list:
i.         The C language is not tied to any particular operating system. It can be used to develop new operating system. Major parts of popular operating systems like Windows, UNIX, Linux is still written in C. This is because even today when it comes to performance (speed of execution) nothing beats C. Moreover, if one is to extend the operating system to work with new device one needs to write device driver program which are exclusively written in C.
ii.          C is the base of most high-level and Object Oriented Programming Language such as C++, Java, C# and Objective C and it is hard to learn C++ or Java directly without learning C. 
iii.            Mobile device and embedded system have limited amount of memory. Considering this constrains C is a very good choice for building operating system and programs for such device for its efficiency and faster execution.
iv.            At times one is required to very closely interact with the hardware device. Since C provides several language elements that make this interaction feasible without compromising the performance it is the preferred choice of the programmer.
v.          C is a structural language. Structured language facilitates the development of a variety of programs in small modules or blocks. It is easy for writing, testing, debugging and maintenance with structured programming.
vi.         C programs are efficient, fast and highly portable, i.e. C programs written on one computer can run on another with small or almost no modification.
vii.     C is a free-form language. Multiple statements can be on the same line or can continue over multiple lines. White spaces (i.e. tab space or space bar) are ignored.
As these features show, C is an excellent choice for your first programming language. In learning C, you are not only learning one of today’s most powerful and popular programming languages, but you are also preparing yourself for object-oriented programming.

C is a middle-level language
C is often called a middle-level computer language. This does not mean that C is less powerful, harder to use, or less developed than a high-level language nor does it imply that C has the cumbersome nature of assembly language. Rather, C is thought of as a middle-level language because it combines the best elements of high-level language with the control and flexibility of assembly languages. In C, one can develop a program first and execute fast. It reduces the gap between high-level and low-level language; that is why it is known as a middle-level language.

C is a case-sensitive language
C is a case-sensitive language means that compiler distinguishes uppercase and lowercase letters.  Thus, in C the word main, Main and MAIN represent three distinct and different names. For this reason we should type all names in the same case.

Structure of a C program
Basic structure of a C program contains the following sections:
i.  Preprocessor Statements: The preprocessor statements begin with # (pound) symbol and are also called preprocessor directive. These statements instruct the compiler to include C preprocessor such as header files and symbolic constants before compiling the program. It is optional means a C program may not contain any preprocessor statements, but generally every C program depends upon some header files for function definition used in the program and for this contains one or more preprocessor statements. Each header file has extension ‘.h’. Header files contain the definitions of C library functions.
ii.  Global Declaration: This section declares some variables that are used in more than one function. These variables are known as global variables and are declared outside any function including main ( ). Global variables can be accessed by all the used define function as well as main ( ) function. Global declaration is also optional and a C program may or may not contain this.
iii.  The main ( ) function: Each and every C program must contain main ( ) function. Every C program starts execution from main ( ) function. No C program is executed without main ( ) function. The main ( ) function should be written in small (lowercase) letters.
iv.  Braces: Every C program must have a pair of curly braces ({, }) and must start immediately after the closing parenthesis of main ( ) function. The left brace (opening brace) indicates the beginning of the definition of main ( ) function and right brace (closing brace) indicates the end of the main ( ) function. Between these two braces, the program should have declaration and executable statements. These braces can also be used to specify the beginning and ending of user-define function. These two braces can also be used in compound statements.
v.    Local Declaration: Some variables are declared inside a function and are called local variable. A local variable can only be accessed from a function where it is declared. This portion is optional for a C program.
vi.   Program Statements: These statements are building blocks of a program. They represent the instruction for the computer to perform any specific task (operation).This portion may contain one or more input output statements, arithmetic statements, decision statements, control statements or assignment statements. Each statement should be terminated with a semicolon.
vii.  User-define Function: The functions defined by the user (programmer) are called user-define function. These are subprograms and perform user specific task. They may be written before or after the main ( ) function and generally called within main ( ) function. Unlike main ( ) function user-define function is optional to the programmer.
viii. Comments: Comments are not necessary in a program. However, to make the program understandable programmer can insert comments in the program. Compiler does not compiler comments but it is useful for documentation. The clarity of the program can be amplified if it is properly documented.
Comments are statements that give us information about the program or logics of program. Comments can be single line or multiline. Single line comments starts with the delimiters ‘//’ and terminate with the end of the line. Multiline comments are to be placed between the delimiters ‘/*’ and ‘*/’. Multiline comments can be nested. Comments are not a part of executable statements and compiler does not execute comments. But, for enhancing the readability of the program programmer should use comments and a good programmer frequently do it.      

Advantages of C
i.                   C contains a powerful data definition. The data types supported are characters, alphanumeric, integers, long integers, floats and double. It also supports string manipulation in the form of character array.
ii.                 C supports a powerful set of operators.
iii.              It also supports powerful graphics programming and directly operates with hardware. Execution of the program is faster.
iv.              An assembly code can also inserted into C program.
v.                 C programs are highly portable on any type of OS platforms.
vi.              System programs such as compiles, operating systems and device driver can be developed in C. For example operating system UNIX is developed in C.
vii.            The C language has 32 keywords and about 145 library functions and near about 30 header files in ANSI C.
viii.         C works closely with machine and matches assembly language in many ways.
ix.              The programs written in C language are efficient, fast and easy to understand.
x.                 Another important advantage of C is its ability to extend itself. We can easily add our own functions in standard C library.

xi.              C language is a structured programming language. This makes user to think of a problem in terms of function modules or blocks. Collections of these modules make a complete program. This modular structure makes program debugging, testing and maintenance easier. 

Introduction of Programming

Introduction to Programming
Computers are really very dumb machines and cannot do anything without instruction. They do only what they are told to do. Most computer systems can perform some very basic operation such as adding two binary digits or testing whether a number is equal to zero. The basic operation a computer can perform is known as computer’s instruction set.
To solve a problem using a computer one must express the solution of the problem in term of the instruction of the particular computer. A computer program is just a collection of the instructions necessary to solve a specific problem. More formally, a computer program is a sequence of instructions that is used to operate a computer to solve a specific problem and produce expected result.

Programming Language
A language is the method to communicate another person or community and a programming language is the method to communicate or instruct computer. More formally, a programming language is a standardized communication technique for describing instructions for a computer. Each programming language has a set of syntactic and semantic rules used to define computer programs. A language enables a programmer to precisely specify what data a computer is to act upon, how these data are to be stored/transmitted and what actions are to be taken under various circumstances.   
On a fundamental level, all computer programs do the same thing. They direct a computer to accept data (input), to manipulate the data (process), and to produce desire result (output). This implies that all computer programming languages must provide essentially the same capabilities for performing these operations.
If all programming languages provide essentially the same features, why are there so many of them? The answer is that there are vast differences in the types of input data, calculations needed, and output reports required by various applications. For example, scientific and engineering application required high-precession numerical outputs, accurate to many decimal places. In addition, these applications typically use many algebraic and trigonometric formulas to produce their results. For such applications, the FORTRAN programming language, with its algebra like instruction, was initially developed. FORTRAN, whose name is an acronym derived from FORmula TRANslation, was introduced in 1957.
Business applications usually deal in whole numbers, representing inventory quantities, for example, dollars and cents data accurate to only two decimal places. These applications require simpler mathematical calculations than are needed for scientific applications. The outputs required from business programs frequently consists of report containing extensive columns of neatly formatted dollars and cents numbers and totals. For these applications the COBOL programming language, with its picture output formats, is an ideal language. COBOL, which was commercially introduced in the 1960s, stands for COmmon Business Oriented Language.   

Types of Programming Language
Programming languages are classified mainly in two categories on the basis of creating instruction.
v Low level language
v High level language

Low level language
These are much closer to hardware. Before creating a program in low level language it is required to have through knowledge of the hardware. A program cannot be run on different hardware. Low level languages are specific to hardware but they run faster compare to high level language. Low level language is also divided in two types.
v Machine language
v Assembly language

Machine language
Machine language is also known as binary language is the only language a machine or computer can understand. Why? Because, a computer is an electronic machine, it can feel only electricity. It cannot understand human languages. So computer can understand a language which is directly related to electricity. Binary language consists of only two digits (0 and 1), is directly related to electricity where 0 represent low voltage and 1 represent high voltage. While easily understood by computers, machine languages are almost impossible for humans to write. Early computers were programmed using machine language. Programs written in machine language are faster and efficient. Writing program in machine language is very tedious, time consuming, difficult to find bugs in longer programs.

Assembly language
To overcome the difficulties of programming in machine language assembly language was developed. An assembly language contains the same instructions as a machine language, but each instruction has a symbol instead of just numbers. These symbols are called mnemonic or opcode. For example if 10111001 is the number to add two numbers, ADD could be used to replace it. After developing assembly language, it was easier to program using symbol instead of numbers. But the program written in assembly language must be converted to machine language which could be done by assembler. Each type of CPU has its own machine language and assembly language instruction. So an assembly language program written for one type of CPU won’t run on another. This shows that assembly language is also machine dependent and time consuming. Programmers still use assembly language when speed is essential or when they need to perform an operation that isn’t possible in a high-level language.

High level language
The languages are called high level language if their syntax is closer to human language. High level languages were developed to make programming easier. Most of the high level languages are English like languages. They use familiar English words, special symbols (!, &, # etc), and mathematical symbols (+, - , * % etc) in their syntax. Therefore high level languages are easier to read, write, understand and programming, which is the main advantage of high level language over low level language. Each high level language has their own set of grammar and rules to represent set of instructions. Programming language such as C, C++, C#, Java, FORTRAN, BASIC, Pascal, Lisp, Python, PHP, Ruby, Perl, R are some examples of high level language. These enable a programmer to write programs that are more or less independent of a particular type of computer. Like assembly language programs, programs written in a high-level language also need to be translated into machine language. This can be done either by a compiler or an interpreter.

Assembler, Compiler and Interpreter
A computer will not understand any program written in a language, other than machine language. The program written in other languages is called source program and must be translated into machine language, which is called an object program. A translator is required for such translation. There are three types of translator programs.
Translators are as follows.
v Assembler
v Compiler
v Interpreter

Assembler
A program which translate assembly language program into a machine language is called an assembler. If an assembler which run on a computer and produce the machine code for the same computer then it is called self assembler or resident assembler. If an assembler that run on a computer and produce the machine code for other computer then it is called Cross Assembler. Assembler checks each instruction for its correctness and generates diagnostic messages, if there are mistakes in the program.

Compiler
It is a program which translates a high level language program into a machine language program. The program which is to be translated is called source program and after translation the object code is generated. The source program is input to the compiler. The object code is output for the secondary storage device. The entire program will be read by the compiler first and generates the object code.  A compiler is more intelligent than an assembler. It checks all kinds of limits, ranges, errors etc. But it takes more time to run and occupies a larger part of the memory. It has slow speed.

Interpreter
An interpreter is a program which translates statements of a program into machine code. Unlike compiler interpreter translates only one statement of the program at a time. It reads only one statement of a program, translate it and execute it. Then it reads the next statement of the program again translate it and execute it. In this way it produces further till all the statements are translate and execute. On the other hand, a compiler goes through the entire program and then translates the entire program into machine codes. A compiler is 5 to 25 times faster than interpreter.

By the complier, the machine codes are saved permanently for future reference. On the other hand, the machine codes produced by interpreter are not saved. An interpreter is a small program compare to compiler. It occupies less memory space, so it can be used in a system which has limited memory space.

Friday, August 21, 2015

My old phone + arduino = phonoduino


Hi, this is a project off my old nokia 1100 phone and arduino mega. By using this many arduino and gsm based project is possible. The phone will work like a gsm module and you can sent message or call someone by using this phonoduino. You can also receive DTMF signal and control anything remotely. It can be used for home automation, home security and monitoring, bird feeder or anything you like. You can also type sms by computer keyboard and send instantly to someone or group by using arduino serial monitor. If you used multimedia phone instead of nokia 1100 you can sent image to another mobile or e-mail by this project. Following are the step by step guide for making the thing.

Step 1: Required Component


1. Old but working phone (I am using nokia 1100 but other phone will also work without touch phone)
2. Arduino Mega (UNO has less number of pin and can be used if DTMF is not required)
3. General purpose NPN transistor (2N2222 or BC547 x 16)
3. DTMF decoder IC (M-8870)
4. Resistors (5.6kΩ x 16, 100kΩ; 70kΩ; 390kΩ)
5. Capacitors (0.1µFx 2)
6. Crystal oscillator (3.579545MHz)
7. Vero-board and some wire

By this phonoduino ( arduino + phone) you can:

1. Call automatically from phone by arduino
2. Sent sms from computer or PC via arduino serial monitor
3. Controll light, fan, LED from remote place via phone
4. Control any thing using DTMF

To know details about phonoduino click here