C Tutorial Programs (As per youtube)

Program 6-How to add & subtract & multiply & divide two numbers in C

Program 7-All arithmetic operations in C

Program 8-Increment Operator Pre Increment & Post Increment in C

Program13-Relational Operators in C

Program20-How to use else if statement in C

Program21-Switch case statement in C

Program22-While loop in C

Program23-Do While loop in C

Program24-For loop in C

Program25-Nested loop in C

Program26-Difference between break and continue statements

Program27-One dimensional array in C

Program28-Two dimensional array in C

Program29-How to use character variable in C

Program30-How to read a character variable using scanf

Program33-How to print a string by using printf

Program34-How to read a string by using scanf

Program35-How to use getchar in C

Program36-How to use putchar in C

Program37-How to use gets in C

Program38-Usage of puts in C

Program39-How to use getch in C

Program40-How to use getche in C

Program41-How to join two strings using strcat

Program42-How to join two strings using strncat

Program43-How to compare two strings using strcmp

Program44-How to compare two strings using strncmp

Program45-How to tell which word first comes in dictionary out of given 2 words

Program46-How to use strcpy in C

Program47-How to use strncpy in C

Program48-How to find length of a string using strlen

Program49-Usage of function in C

Program50-How to create a functions for adding or subtracting or multiplying or dividing 2 numbers

Program51-Passing parameters to function using call be reference technique

Program52-Difference between call by value and call by reference

Program53-Swapping of 2 given numbers

Program54-Understanding the concept of call by value using swapping of 2 numbers

Program55-Understanding the concept of call by reference using swapping of 2 numbers

Program56-Usage of return statement in C

Program57-How to declare and initialize the integer pointer variable

Program58-How to declare and initialize the character pointer variable

Program59-How to perform the arithmetic operations on pointer that is pointing to integer

Program60-How to perform the arithmetic operations on pointer that is pointing to character

Program61-How to declare a structure

Program62-How to declare a structure variable

Program63-How to initialize a structure variable

Program64-How to access members of a structure

Program65-How to find size of a structure

Program66-Concept of structure Assignment

Program67-Usage of UNION in C

Program68-How to print back slash and double quote

Program69-Preprocessor directives in C

Program70-Conditional preprocessor directives in C

Program71-Macro parameters substitution using preprocessor directives in C

Program72-To find whether a given year is leap year or not

Program73-To find the biggest of three numbers

Program74-To check whether a given number is even or odd by using bitwise logical operator

Program75-To check whether a given character is vowel or consonant

Program76-To perform arithmetic operations using switch case statement

Program77-Sum of n natural numbers using while loop

Program78-To find sum of digits of a given number

Program79-To check whether a given number is ARMSTRONG or not

Program80-To find factorial of a given number using for loop

Program81-To print even and odd numbers from 1 to given number

Program82-To print Fibonacci series

Program83-To check whether a given number is prime number or not

Program84-To print prime numbers between two given numbers

Program85 -To print a given integer in reverse order

Program86 -To check whether a given number is PALINDROME or not

Program87-To find the highest value of an array

Program 87b -To find the highest value of an array

Program88-Printing array elements in ascending order

Program89-Sum of elements of array

Program90-To find factorial of given number using function call techniques

Program91-Addition of 2 matrices

Program92-Multiplication of 2 matrices

Program93-Pattern Printing

Program94-Pattern Printing

Program95-Pattern Printing

Program96-Pattern Printing

Program97-Pattern Printing

Program 97b-Pattern Printing

Program 97c-Pattern Printing


Controlling appliances by RF communication using HT12E & HT12D

The main objective of this project is to learn wireless communication by using HT12E (ENCODER) and HT12D (DECODER) and a pair of RF modules of 433 MHz. After doing this project you will be able to
1)  Control any 4 loads by using wireless remote without any WIFI or Blue tooth or internet
2)  Set security lock to your remote such that the loads are controlled by your remote only but not by any other remote


By using the paired HT12E encoder and HT12D decoder we can easily transmit and receive 12 bits of parallel data serially. HT12E simply converts 12 bit parallel data in to serial output which can be transmitted through a RF transmitter. These 12 bit parallel data is divided in to 8 address bits and 4 data bits. By using these address pins we can provide 8 bit security code for data transmission and multiple receivers may be addressed using the same transmitter
 

HT12E Pins

  • VCC (18th PIN) - 5 Volts supply positive terminal is connected to this pin
  • GND (9th PIN) - This pin is connected to ground
  • OSC1 (16th PIN) and OSC2 (15th PIN) are used to connect external resistor (47Kilo Ohms) for internal oscillator of HT12E. OSC1 is the oscillator input pin and OSC2 is the oscillator output pin
  • A0 – A7 (PIN 1 to PIN 8) are the address input pins. Status of these pins should match with status of address pins in HT12D  to receive the data. Often these pins can be connected to VCC or left open.
  • TE (14th PIN) is used for enabling the transmission and is an active low input.
  • AD0 – AD3 (PIN 10 to PIN 13) are the input data pins. These pins can be connected to VCC or may left open for sending LOW and HIGH respectively.
  • DOUT (17th PIN) is the serial data output pin which is connected to RF transmitter input

HT12D Pins
  • VCC (18th PIN) - 5 Volts supply positive terminal is connected to this pin
  • GND (9th PIN) - This pin is connected to ground
  • OSC1 (16th PIN) and OSC2 (15th PIN) are used to connect external resistor (47Kilo Ohms) for internal oscillator of HT12D. OSC1 is the oscillator input pin and OSC2 is the oscillator output pin
  • A0 – A7 (PIN 1 to PIN 8) are the address input pins. Status of these pins should match with status of address pin in HT12E (used in transmitter) to receive the data. Often these pins can be connected to VCC or left open.
  • DIN (14th PIN) is the serial data input pin and can be connected to a RF receiver output
  • D0 – D3 (PIN 10 to PIN 13) are the data output pins. Status of these pins can be VCC or ground depending upon the received serial data through pin DIN
  • VT (PIN 17) stand for Valid Transmission. This output pin will be HIGH when valid data is available at D8 – D11 data output pins.
Here Address bits A0 to A7 on both the Encoder and Decoder IC can be grounded. This means that they are both kept at address 0b00000000. This way they both share the same address and they will act as a pair.







Creative works of 19208,18208,17208 DECE students




These creative works are drawn/written by DECE students of Government polytechnic amadalavalasa. One topic of Electronic Devices and power supplies(EC-105) is assigned to each student, and the students are asked to relate the concept of this topic to any thing around you. The motto behind asking the students to link the subject to the things around them is 
1)To create the interest in the students about the subject, which will give them chance to remember the basic concepts even after years. This will be useful in the present competitive world to remember the concepts until the objective exams and to perform well in interviews
2) To create an awareness about thinking social problems surrounding them


1.2-Classification of resistors (19208-EC-033)

1.2-Classification of resistors(18208-EC-003)

1.2-Classification of resistors(17208-EC-017)

1.3-Specifications of resistor (19208-EC-004)

1.4-Physical factors affecting value of resistor (19208-EC-005)

1.4-Physical factors effecting the resistor-Part2(19208-EC-005)

1.5-Identification of resistance value by using colour code(19208-EC-006)

1.8-Effect of temperature on resistance(19208-EC-010)

1.9-Temperature coefficient of resistance(19208-EC-011)

1.10-Thermistor & sensistor(19208-EC-012)

1.10-Thermistor & Sensistor(17208-EC-015)

1.11-Definition of Inductance(19208-EC-013)

1.14-Specifications of inductors(19208-EC-015)

1.16-Various core materials in contruction of inductors(19208-EC-018)

1.18-AF Choke & RF chokes(19208-EC-020)

1.19-Definition of capacitance(19208-EC-021)

1.19-Definition of capacitance(17208-EC-001)

1.19-Define capacitance(17208-EC-002)

1.20-Classification of capacitors(19208-EC-023)

1.21-Specifications of capacitor(19208-EC-024)

1.24-Variable Capacitors(19208-EC-028)

1.24-Variable Capacitors(17208-EC-028)

Chapter 1-Resistance & Capacitance(17208-EC-041)

2.1-Working of a switch(19208-EC-030)

2.1-Working of a switch(17208-EC-003)

2.1-Working of switch(17208-EC-002)

2.4-Need of fuse(19208-EC-031)

2.4-Need of fuse (19208-EC-024)

2.4-Need of fuse (17208-EC-014)

2.4-Need of fuse(17208-EC-018)

2.4-Need of fuse(17208-EC-040)

2.4-Need of fuse(17208-EC-002)

2.4-Need of fuse(17208-EC-009)

2.5-Different types of fuses(032)

2.6-Necessity of connectors in electronic circuits (19208-EC-033)

2.7-Different types of connectors(19208-EC-034)

2.8-MCB(17208-EC-008)

2.8-MCB(17208-EC-032)

2.8-MCB(17208-EC-025)

2.10-Classification of Relays(19208-EC-037)

2.11-Applications of Relays(17208-EC-038)

2.12-Working of Relay(19208-EC-036)

2.12-Working of relay(19208-EC-039)

3.1-Need of PCBs(19208-EC-038)

3.2-Classification of PCBs

3.4-Methods of transferring layout to Copper clad sheet(19208-EC-043)

3.5-Steps involved in screen printing for making PCBs(19208-EC-044)

3.6-Screen Printing(19208-EC-045)

3.7-Etching, cleaning, drilling methods of PCB(19208-EC-046)

3.11-Soldering materials(19208-EC-051)

3.11-Soldering materials(17208-EC-027)

3.12-Soldering methods of PCBs(19208-EC-052)

4.3-Comparision of Conductors,Semo conductors,Insulators(19208-EC-055)

4.3-Conductors,Semi conductors, Insulators(17208-EC-023)

4.4-Energy Band Diagrams of Semiconductor materials(19208-EC-056)

4.7-Extrinsic semiconductors(19208-EC-004)

4.8-Majority & minority carriers in P,N type semiconductors(19208-EC-005)

4.9-Diffusion & Drift currents (19208-EC-052)

5.2-PN Diode in Forward & Reverse bias(19208-EC-010)

5.4-Potential barrier(19208-EC-012)

5.8-Avalanche, zener diodes(19208-EC-014)

5.9-Specifications of diode (19208-EC-015)

6.11- Comparision of input resistance of a transistor when it is connected in CB,CE,CC configurations(19208-EC-024)

6.11- Comparision of output resistance of a transistor when it is connected in CB,CE,CC configurations(19208-EC-024)

6.11- Comparision of voltage gain of a transistor when it is connected in CB,CE,CC configurations(19208-EC-024)

6.11- Comparision of current gain of a transistor when it is connected in CB,CE,CC configurations(19208-EC-024)

6.11- Comparision of leakage current of a transistor when it is connected in CB,CE,CC configurations(19208-EC-024)

7.2-Junction Field Effect Transistor construction & Operation(19208-EC-028)

7.6-Advantages of JFET over BJT(19208-EC-032)

7.9-Comparision of JFET and MOSFET(19208-EC-036)

7.10-Drain & Transfer characteristics of MOSFET(19208-EC-037)

8.2-Rectifier(19208-EC-039)

8.12-Bleeder Resistor (19208-EC-046)

8.14-Regulated Power Supply (19208-EC-050)

8.15-Zener Regulator (19208-EC-051)

Story on Chapter 1 (Passive Components) (By 19208 students)

Story on 1,2 Chapters(17208-EC-043)

Story on Chapter 3 (PCB)(By 19208 students)

Story on chapter 4 (Semiconductor Physics)(By 19208 students)

Story on chapter 5 (Semiconductor Diode)(By 19208 students)

Story on Chapter 6 (BJT)(By 19208 students)

Story2 on Chapter 6(BJT) (By 19208 students)

Story on Entire Electronic Devices and Power Supplies (EC-105)(By 19208 students)

Brain Teasers on Chapter 1 & Chapter 2(18208-EC-003)

Switch, PCB stories(18208-EC-003)

Story on capacitor & resistor-Chapter 1 (18208-EC-003)

Chapter 1 conversation(17208-EC-031)

Chapter 2-Fuse,Relay, Switch conversation(17208-EC-005)

Chapters 1,2 story(17208-EC-022)

Chapter 3-PCB(17208-EC-013)

Chapter 1 Poetry(17208-EC-015)

Story on EDPS(17208-EC-024)

Diagram on EDPS(17208-EC-019)

Poetry on chapter 1 (17208-EC-050)

Story on EDPS(17208-EC-012)

GUI Based Home Automation System Using Arduino and MATLAB

In this project, we are using MATLAB with Arduino to control the Home appliances, through a Graphical User Interface in Computer. Here we have used wired communication for sending data from computer (MATLAB) to Arduino. In computer side, we have used GUI in MATLAB to create some buttons for controlling home appliances. For communication between Arduino and MATLAB, we first need to install the “MATLAB and Simulink Support for Arduino” or “Arduino IO Package”. To do so follow the below steps or check the video below:

1) Download the Arduino IO Package from here. You need to Sign up before download.

2) Then Burn/upload the adioe.pde file to the Arduino using Arduino IDE. This adioe.pde file can be found in Arduino IO Package – ArduinoIO\pde\adioe\adioe.pde
3) Then open the MATLAB software, go through the Arduino IO folder, open the install_arduino.m file and Run it in Matlab. You will see a message of “Arduino folders added to the path” in command window of MATLAB, means MATLAB path is updated to Arduino folders.


That’s how we make the Arduino, communicate with MATLAB. Above method is suitable for “MATLAB R2013b or earlier versions”, if you are using the higher version of MATLAB (like R2015b or R2016a), you can directly click on Add-ons Tab in MATLAB and then click “Get Hardware Support Packages”, from where you can install Arduino packages for MATLAB.

After installing files, now you can create a GUI for Home Automation Project. Basically in GUI, we are creating Push Buttons for controlling the home appliances from computer. Buttons can be created by going into “Graphical User Interface” in “New” menu in MATLAB. Further we can set the name and colours of these buttons, we have created 8 buttons, in which six to ON and OFF three home appliances and two buttons to ON and OFF all the appliances simultaneously.

Now after creating the buttons, when you click on Run button in that GUI window, it will ask you to save this GUI file (with extension .fig), also known as ‘fig file’. As soon you saved the file, it will automatically create a code file (with extension .m), also known as ‘M file’ (see below screen shot), where you can put the Code (given in Code section below). You can download the GUI file and code file for this project from here:
Home_Automation_system.fig and Home_Automation_system.m (right click and select Save link as...), or you can create them yourself like we have explained.



After coding you can now finally Run the .m file from the code window, you will see “Attempting connection..” in the command window. Then a “Arduino successfully connected” message appears, if everything goes well. And finally you will see previously created GUI (buttons) in GUI window, from where you can control the home appliances by just clicking on the buttons in your Computer. Make sure that Arduino is connected to Arduino via USB cable. Here in this project we have used 3 bulbs for demonstration, which indicates Fan, Light and TV.

Working of the whole project, from installing the Arduino MATLAB support package to Turn On or OFF the appliance, can be understood at the Video at the end.


Circuit Explanation:
Circuit of this project is very easy. Here we have used an Arduino UNO board and Relay Driver ULN2003 for driving relays. Three 5 volt SPDT Relays are connected to Arduino pin number 3, 4 and 5, through relay driver ULN2003, for controlling LIGHT, FAN and TV respectively.


Programming Explanation:
When we press any button from the GUI window then it sends some commands to Arduino and then Arduino do that operation. After installing Arduino MATLAB IO support package, we can access Arduino from the MATLAB by using the same Arduino functions, with some little variation, like:
For making a pin HIGH in Arduino we write code as digitalWrite(pin, HIGH)

In MATLAB we will use this function with the help of an object or variable like,
a.digitalWrite(pin, HIGH);

and likewise so on.

Before doing this we have to initialise variable like this:
a = Arduino(‘COM1’); // change COM1 according to your port


In this project, there is no Arduino code except the Arduino MATLAB support package code or file. As explained earlier that code file (.m file) is automatically generated while saving the GUI file (.fig file). There is already some code prewritten in .m file. Basically these are Callback functions for Push buttons, means we can define what should happen on clicking on these Push Buttons.


In MATLAB code, first we initialise serial port and make it an object by using a variable. And then we can start programming like Arduino using the variable.

clear ar;
global ar;
ar=arduino('COM13');
ar.pinMode(3, 'OUTPUT');
ar.pinMode(4, 'OUTPUT');
ar.pinMode(5, 'OUTPUT');
ar.pinMode(13, 'OUTPUT');
In the call back function of each button, we have written the related code for On or OFF the respective Home Appliances, connected to Arduino via Relay. Like for example, Callback function for Light ON is given below:

function light_on_Callback(hObject, eventdata, handles)
% hObject    handle to light_on (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ar;
ar.digitalWrite(3, 1);
ar.digitalWrite(13, 1);
Likewise we can write the code in the Callback functions of all the buttons, to control the other connected Home Appliances, check the full MATLAB Code below (.m file).
Code
function varargout = Home_Automation_system(varargin)
% HOME_AUTOMATION_SYSTEM MATLAB code for Home_Automation_system.fig
%      HOME_AUTOMATION_SYSTEM, by itself, creates a new HOME_AUTOMATION_SYSTEM or raises the existing
%      singleton*.
%
%      H = HOME_AUTOMATION_SYSTEM returns the handle to a new HOME_AUTOMATION_SYSTEM or the handle to
%      the existing singleton*.
%
%      HOME_AUTOMATION_SYSTEM('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in HOME_AUTOMATION_SYSTEM.M with the given input arguments.
%
%      HOME_AUTOMATION_SYSTEM('Property','Value',...) creates a new HOME_AUTOMATION_SYSTEM or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Home_Automation_system_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Home_Automation_system_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Home_Automation_system
% Last Modified by GUIDE v2.5 28-Feb-2016 01:59:17
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Home_Automation_system_OpeningFcn, ...
                   'gui_OutputFcn',  @Home_Automation_system_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Home_Automation_system is made visible.
function Home_Automation_system_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Home_Automation_system (see VARARGIN)
% Choose default command line output for Home_Automation_system
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
clear ar;
global ar;
ar=arduino('COM13');
ar.pinMode(3, 'OUTPUT');
ar.pinMode(4, 'OUTPUT');
ar.pinMode(5, 'OUTPUT');
ar.pinMode(13, 'OUTPUT');
% UIWAIT makes Home_Automation_system wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Home_Automation_system_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in light_on.
function light_on_Callback(hObject, eventdata, handles)
% hObject    handle to light_on (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ar;
ar.digitalWrite(3, 1);
ar.digitalWrite(13, 1);
% --- Executes on button press in light_off.
function light_off_Callback(hObject, eventdata, handles)
% hObject    handle to light_off (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ar;
ar.digitalWrite(3, 0);
ar.digitalWrite(13, 0);
% --- Executes on button press in fan_on.
function fan_on_Callback(hObject, eventdata, handles)
% hObject    handle to fan_on (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ar;
ar.digitalWrite(4, 1);
% --- Executes on button press in fan_off.
function fan_off_Callback(hObject, eventdata, handles)
% hObject    handle to fan_off (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ar;
ar.digitalWrite(4, 0);
% --- Executes on button press in tv_on.
function tv_on_Callback(hObject, eventdata, handles)
% hObject    handle to tv_on (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ar;
ar.digitalWrite(5, 1);
% --- Executes on button press in tv_off.
function tv_off_Callback(hObject, eventdata, handles)
% hObject    handle to tv_off (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ar;
ar.digitalWrite(5, 0);
% --- Executes on button press in all_on.
function all_on_Callback(hObject, eventdata, handles)
% hObject    handle to all_on (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ar;
ar.digitalWrite(3, 1);
ar.digitalWrite(4, 1);
ar.digitalWrite(5, 1);
% --- Executes on button press in all_off.
function all_off_Callback(hObject, eventdata, handles)
% hObject    handle to all_off (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global ar;
ar.digitalWrite(3, 0);
ar.digitalWrite(4, 0);
ar.digitalWrite(5, 0);