EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / // Program to count the

// Program to count the

|

Microcontroller › 8051 › Bluetooth Module interfaing with 8051 microcontroller › // Program to count the

August 30, 2014 at 12:48 am #12091
Nishant
Participant
// Program to count the number of clap
#include<reg51.h>
#define port P1
#define dataport P2 //Data Port for LCD
#define sec 1000
sbit rs = port^0;
sbit rw = port^1;
sbit e = port^2;
sbit sensor_input=P0^0;
unsigned char str3[10]={' ',' ',' ',' ',' ',' ',' ',' ',' ',' '};


void delay(unsigned int msec) // Time delay function
{
int i,j ;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}

void lcd_cmd(unsigned char item) // Function to send command
{
dataport = item;
rs= 0;
rw=0;
e=1;
delay(1);
e=0;
return;
}

void lcd_data(unsigned char item) // Function to send data
{
dataport = item;
rs= 1;
rw=0;
e=1;
delay(1);
e=0;
return;
}

void lcd_data_string(unsigned char *str) // Function to send string
{
int i=0;
while(str!='')
{
i++;
}
while(i>=0)
{
lcd_data(str
);
i--;
delay(10);
}
return;
}

void convert(int num) // Function to extract digits and send to LCD
{
int i=0;
while(num>0)
{
str3
=(num%10)+48;
num=num/10;
i++;
}
str3
='';
}

void main()
{
int count=0;
sensor_input=1;
sensor_input=0;
lcd_cmd(0x38);
lcd_cmd(0x0e);
lcd_cmd(0x01);
while(1)
{
sensor_input=0;
while(sensor_input==0);
if(sensor_input==1)
{
lcd_cmd(0x01);
count++;
convert(count);
lcd_cmd(0x82);
lcd_data_string(str3);
}
}
}

RSS feed: Recent Posts Recent Posts

  • Advice for an ESP32 Soil Tensiometer project with 5V sensors September 4, 2026
  • Control diesel fuel injector September 3, 2026
  • Smoothing out Resistive Power Draw with PWM September 3, 2026
  • Deacy Amp circuit diagram? September 2, 2026
  • Need to control diesel fuel injector using microcontroller September 1, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 Arrowfly LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of Arrowfly
Privacy Policy | Advertising

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise