Connect to

facebook google Email you tube you tube you tube
Theme images by MichaelJay. Powered by Blogger.

Projects

Code Catalogue You've probably noticed

We Love What We Do.

About Us


Expertise

We just don't make programs. We expertise in making Optimised programs and providing best solutions to our end-customers

Our Services

We provide the best tutorials with video classes along. Also we guide through project making for CBSE.We also provide branding for your companies.

Efficiency

Reaching the level of excellence in teaching concepts. And solving the queries and making efficient products for our customers.

Contact

Contact us by filling just 3 step form and we will get back to you immediately.

Do you like our work so far?
Let's talk about your project !

GET IN TOUCH

Projects


Main Blog
Our Recent Posts

25.7.20

Pet Feeder using Arduino Uno

Today we ll be learning how to make an Automatic Pet Feeder using Arduino UNO board.
We'll also be using a RTC board coupled with our UNO board to keep a date and time track.

Materials Required
  • Arduino Uno
  • 4*4 or 3*4

    Matrix Keypad
  • 16*2 LCD
  • Push Button
  • Resistors
  • Connecting Wires
  • Servo Motor(non metal works)
  • Breadboard
  • DS3231 RTC Module
DS3231 RTC Module, where RTC stands for Real Time Clock is used to keep a track of Date and Time. It is powered by its own supply just like CMOS battery in our desktop or laptop motherboards.
You can order one from here.

When using this module for the first time you have to set the date and time.
You can find the library for RTC module here.


So first we'll make our connections this way :



Code :
#include <DS3231.h>
#include <Servo.h>
#include <LiquidCrystal.h>
#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Three columns

// Define the Keymap

char keys[ROWS][COLS] = {

  {'1','2','3','A'},

  {'4','5','6','B'},

  {'7','8','9','C'},

  {'*','0','#','D'}

};

// Connecting the keypad (Rows)

byte rowPins[ROWS] = { 2, 3, 4, 5 };

// Connecting the keypad ( Columns)

byte colPins[COLS] = { 6, 7, 8, 9 };

//  Create the Keypad
  Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

DS3231  rtc(A4, A5);
Servo servo_test;      //initialize a servo object for the connected servo  
LiquidCrystal lcd(A0, A1, A2, 11, 12, 13); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)

 int t1, t2, t3, t4, t5, t6;

 
boolean feed = true; // condition for alarm

 char key;
 int r[6];
 
 void setup() 
 { 
  servo_test.attach(10);   // attach the signal pin of servo to pin9 of arduino
  rtc.begin();
  lcd.begin(16,2);
  servo_test.write(55); 
  Serial.begin(9600);
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  pinMode(A2, OUTPUT);
  
 } 
 
 void loop() 
 { 

lcd.setCursor(0,0);
int buttonPress;
buttonPress = digitalRead(A3);

if (buttonPress==1)
 setFeedingTime();
 

//Serial.println(buttonPress);

 lcd.print("Time:  ");
 String t = "";
 t = rtc.getTimeStr(); 
 t1 = t.charAt(0)-48;
 t2 = t.charAt(1)-48;
 t3 = t.charAt(3)-48;
 t4 = t.charAt(4)-48;
 t5 = t.charAt(6)-48;
 t6 = t.charAt(7)-48;
 
 lcd.print(rtc.getTimeStr());
 lcd.setCursor(0,1);
 lcd.print("Date: ");
 lcd.print(rtc.getDateStr());
 
 if (t1==r[0] && t2==r[1] && t3==r[2] && t4==r[3]&& t5<1 && t6<3 && feed==true)
 { 
  servo_test.write(100);                   //command to rotate the servo to the specified angle 
   delay(400);   
  servo_test.write(55); 
  feed=false;
 } 
 }       

void setFeedingTime()
{
  feed = true;
   int i=0;

  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Set feeding Time");
  lcd.clear();
  lcd.print("HH:MM");
  lcd.setCursor(0,1);

  
  while(1){
    key = kpd.getKey();

    char j;
    
  if(key!=NO_KEY){
    
    lcd.setCursor(j,1);
    
    lcd.print(key);
    
    r[i] = key-48;
    i++;
    j++;

    if (j==2)
    {
      lcd.print(":"); j++;
    }
    delay(500);
  }

  if (key == 'D')
  {key=0; break; }
  }
}




23.7.20

Implementation of Stacks Using Linked List in C++ and C

As we have discussed about Static Stacks in one of our previous article where we also talked about the definition of stacks ie Stacks are kind of non primitive data structure where NON Primitive means derived from basic data types.

In the article we will be studying about Dynamic Stacks. Now when the word Dynamic comes it means we will be talking about implementation of stacks using Linked List.

For a better understanding of our video on Dynamic Stacks you should know about the traversal of linked list which is available here.

Before Starting  I would like to make a few points clear. Which are :

  1. What is a Linked List?
  2. Difference between Linked List and Array.
  3. Differences between Static Stacks and Dynamic Stacks. 
1. Linked List :
A linked list is a set data collection (each called a NODE) each containing the address of its successor or predecessor or both depending on the type of the linked list.
In the above picture we see a Singular linear linked list where each node contains the address of the successive node.
For More information about Basic concept anf Traversal of Linked List click here.

2. We will be going through the major difference only in this article which is that in case of an array we have random access memory moreover the size of the array has to be mentioned before which makes it static and also the wastage of memory is also a disadvantage of arrays. On the contrary in case of linked list the memory allocation is Dynamic and so we don't have to mention the size and also no wastage of memory. This concept would be more clear in our article of linked list.

3. Difference between Static Stacks and Dynamic Stacks.
In case of Static Stacks we have to mention the size first and so it makes it a constraint the no of elements is fixed.
Whereas in case of dynamic stacks the constraint of size is not a problem as the size is not fixed and so we can push(insert) as many elements into the stack as we want.

Now Coming to our topic



We have the source code in C++

// Dynamic Stacks

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>


struct node
 { int adno;
   char name[20];
   float mks;
   node *link;
   };
node *top;

void push()
 { node *ptr;
   ptr=new node;
   if(ptr==NULL)
    { cout<<"Overflow";
      exit(0);
      }
   cout<<"\nEnter ADNO ";cin>>ptr->adno;
   cout<<"\nEnter Name ";gets(ptr->name);
   cout<<"\nEnter Marks ";cin>>ptr->mks;
   ptr->link=NULL;
   if(top==NULL)
    top=ptr;
   else
    {ptr->link=top;
     top=ptr;}
     }


void pop()
 { if(top==NULL)
    {cout<<"Under Flow";
     exit(0);
      }
   node *ptr;
   ptr=top;
   top=top->link;
   ptr->link=NULL;
   cout<<"Deleted\n";
   cout<<"\nAdmission Number "<<ptr->adno;
   cout<<"\nNAme "<<ptr->name;
   cout<<"\nMarks "<<ptr->mks;
   delete ptr;
   }

void display()
 { if(top==NULL)
    {cout<<"No Elements to Display";
     getch();
     exit(0);
     }
    node *ptr;
    ptr=top;
    while(ptr!=NULL)
     {  cout<<"\nAdmission Number "<<ptr->adno;
cout<<"\nNAme "<<ptr->name;
cout<<"\nMarks "<<ptr->mks;
cout<<'\n';
ptr=ptr->link;
}
  }


void main()
 {
   char ch;
   do {clrscr();
       cout<<"\nPush an Element     1";
       cout<<"\nPop an Element      2";
       cout<<"\nDisplay Stack       3";
       cout<<"\nExit                4";
       int n;
       cin>>n;
       switch(n)
{ case 1:{ clrscr();
  push();}break;

 case 2:{ clrscr();
  pop();}break;
 case 3:{ clrscr();
  display();}break;
 case 4:exit(0);

 }cout<<"Want to Continue? ";cin>>ch;
   }while(ch=='Y' || ch=='y');
  getch();
  }

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,


Source Code in C


#include<conio.h>
#include<stdio.h>
#include<process.h>

struct node
 { int adno;
   struct node *link;
   };
#define NODE struct node

NODE *top;

void push()
 { NODE *ptr=(NODE*)malloc(sizeof(NODE));
   if(ptr==NULL)
    { printf("Overflow");
      getch();
      exit(0);
      }
   printf("\nEnter ADNO ");
    scanf("%d",&ptr->adno);
   ptr->link=NULL;
   if(top==NULL)
    top=ptr;
   else
    {ptr->link=top;
     top=ptr;}
     }


void pop()
 { NODE *ptr=(NODE*)malloc(sizeof(NODE));

  if(top==NULL)
    { printf("Under Flow");
     exit(0);
      }

    ptr=top;
    top=top->link;
    ptr->link=NULL;
   printf("\nDeleted\n");
   printf("\nAdmission Number %d ",ptr->adno);
   free(ptr);
   }

void display()
 { NODE *ptr=(NODE*)malloc(sizeof(NODE));
   if(top==NULL)
    { printf("\nNo Elements to Display");
      getch();
      exit(0);
    }
    ptr=top;
    while(ptr!=NULL)
     {  printf("\nAdmission Number %d",ptr->adno);

ptr=ptr->link;
     }
  }


void main()
 {
   int ch,n;
   do {clrscr();
       printf("\nPush an Element     1");
       printf("\nPop an Element      2");
       printf("\nDisplay Stack       3");
       printf("\nExit                4\n");
       scanf("%d",&n);
       switch(n)
 { case 1:{ clrscr();
   push();
 }break;

   case 2:{ clrscr();
   pop();
 }break;
   case 3:{ clrscr();
   display();
 }break;
   case 4:exit(0);

   }printf("\nWant to Continue?(yes=1) ");
     scanf("%d",&ch);
   }while(ch==1);
  getch();
  }


Selection Sort C++

Selection Sort is an operation that is performed on arrays.
Out of the 4 ways of sorting arrays which are : Bubble Sort, Selection Sort, Insertion Sort, Merge Sort it is one of the easiest to understand algorithm.
As the name suggests it basically selects 1 element from the array and takes it to the first position. Now the Selection of that element depends upon us, it can be either the smallest element(for ascending order)  or the greatest element(descending order).
So going as per the definition there are two ways in which we can do the same.

  • One can be by swapping the smallest element in the array by the element number on which we are on.
    Eg: if the array was  3 , 8 , 2 , 1
     after 1st pass it becomes 1 , 8 , 2 , 3
              2nd pass  1 , 2 , 8 , 3
               3rd pass 1 , 2 , 3 , 8.
  • The other and the easier way can be by finding the smallest element and bring it to the position on which we are working by swapping irrespective of the element with which we are swapping it with.
We will be talking about the second method.


Now talking about the second method we are basically starting from the 1st element and then comparing it with all elements of the array. As and when we find an element smaller than that particular element we swap. after comparision with all elements we have the smallest element at the 1st position. This process is called 1st pass. Then we will take the next index which would be our next pass or the 2nd pass and comparing it with the next elements.
Now Look at the example Closely :


So thats the 1st pass. Now Look at the 2nd pass  :



So in the second pass you saw 2 was constant and the comparision were from 2nd index and so it goes on to finally gives  2 , 4 , 5 , 6 , 7


Here we have the code in C++ :


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int size, arr[50], i, j, temp;
cout<<"Enter Array Size : ";
cin>>size;
cout<<"Enter Array Elements : ";
for(i=0; i<size; i++)
{
cin>>arr[i];
}
cout<<"Sorting array using selection sort...\n";
for(i=0; i<size; i++)
{
for(j=i+1; j<size; j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
cout<<"Now the Array after sorting is :\n";
for(i=0; i<size; i++)
{
cout<<arr[i]<<" ";
}
getch();
}
For the understanding of this code watch our video on selection sort.



2.6.17

How to input characters without hitting Enter Key in C and C++

Well this is one feature which many of us want to include in our C++ projects.

Firstly what does this statement mean?
When we start learning C/'C++, to input we always use functions like scanf in C and cin in C++. But have you ever tried inputting characters using getch() or getche()?



Before starting What is the getch() function?

Getch() is a nonstandard function and is present in conio.h header file which is mostly used by MS-DOS compilers like Turbo C. It is not part of the C standard library or ISO C, nor is it defined by POSIX (Source: http://en.wikipedia.org/wiki/Conio.h)
It reads also a single character from keyboard. But it does not use any buffer, so the entered character is immediately returned without waiting for the enter key.


Let us see a Program : 


C++ :

#include
#include

 void main()
  { char c;
      c=getch();
      cout<<'\n'<
     getch();
}

C: 

#include
#include

 void main()
  { char c;
      c=getch();
     printf("\n%c",c);
     getch();
}



Our Services


Essential-Books Books Available

Can't find your book?

Fill the form Get in touch
1-zuw13g-EDVIMonayy-Jg-GGA Arduino Guide

Arduino Projects and Tutorials

Want some custom Project? Get in touch
Raspberry-Pi-mini-laptop-project RaspberryPi Guide

Raspberry Pi Guide and Tutorials

Want some custom Project? Get in touch
Capture School/College PRojects

C++, Python, HTML and what not.

Want a custom project? Get in touch

Contact Us


Codes Catalogue
India

r.sachdev1111@gmail.com

Interested in our works and services?
Get more of our update !