Skip to main content

Posts

Showing posts with the label C

Featured Post

Product Design of a 4 wheel differential drive robot

Clap Switch

For some time I was thinking of making a simple clap switch for my room. ( Kind of lazy to go and switch off the light and fan every time... :-) ) First get it work on a breadboard. "Circuit is simple and straight way. Feed the output from the mic to a comparator. The output of comparator will act as the trigger for micro-controller. Micro-controller detects the pattern and enable the corresponding relay switch. Micro-controller always waits for an interrupt (a clap). If a clap is detected it will wait and counts the following claps within a period of 1s. It will discard miss claps and only takes into account the pattern that is programmed. 2 claps means light on/off & 3 claps means fan on/off. There will be separate switch to enable/disable the clap circuit and precedence will be given for the physical switch. That means if the physical switch is on regardless of the relay state light/fan will be ON. If it's not then it will depend on the clap circuit." Co...

Chat/Messenger program using c

Messages send through server program will be displayed in the client side. Port used is 10000. You can change the ip address of server in the client side program. Will update the program to include more features. The program is intended to use in Linux platform. (Compiler  used is gcc). Server Client

Socket Programming in C

This is a simple server client program I wrote in C while learning. The program lacks several error checking. But it works and is simple to understand. Use this code only for learning process. The server send Hello World and the client will print it in the screen. Server program should run first and then the client program in a different terminal. Use this code in a Linux platform. Server Client

Flooding RAM ( C )

This program will dynamically allocate memory and shows the amount of memory it uses. When heap is empty it will show Memory Full. The memory will be freed once you close the program (No harm by the way!). The rate at which memory is allocated is small (1 Kb per each iteration) so you can see at which point heap becomes empty.

Encode your text into ASCII HEX code using C

This C++ code will convert the typing keystrokes from keyboard into it’s ASCII code(HEX). 1: #include<stdio.h> 2: #include<conio.h> 3: 4: char HEXST( char a){ 5: int rem,no= int (a),i=0; 6: char tmp, string [2]; 7: 8: while (no>0){ 9: rem=no%16; 10: no=(no/16); 11: 12: switch (rem){ 13: case 10: 14: tmp='A'; 15: break ; 16: case 11: 17: tmp='B'; 18: break ; 19: case 12: 20: tmp='C'; 21: break ; 22: case 13: 23: tmp='D'; 24: ...