ESY Ch-4_2
ESY Ch-4_2
void delay ( )
{
unsigned int j;
for (j=0; j<5; j++);
}
or
Simple function generator-
Generate square waveform when switch 1 is pressed &
generate saw tooth waveform when switch2 is pressed.
ADC
ADC Interfacing
ADC Interfacing
#include<reg51.h>
delay(2);
void delay (unsigned int);
SC=0;
sbit ALE= P0^2; while(EOC==1); // Wait untill conversion is
sbit OE= P0^0; completed
sbit SC= P0^1; {OE=1;
delay(10);
sbit EOC= P0^4;
// make output enable pin = high
void main (void)
{ ADC_val0ue=P3; //conversion is
unsigned char ADC_value; completed. Now read ADC data on port3.
P1=ADC_value; // Now output that
P3=0xff; //Make port P3 as an input data to LEDs connected to Port1
ALE=0; // make ALE pin low }
SC=0; // make ALE pin low }
OE=0; // make output enable pin low }
void delay(unsigned int t)
P2=0x02; // Channel 1 (Pot) is selected
{
while(1) unsigned int i,j;
{ for (i=0; i<=t; i++)
ALE=1; for (j=0; j<=1000; j++);
delay(2);
ALE=0;
}
delay(2);
SC=1;
Stepper Motor
Stepper Motor Interfacing with 8051
Rotate stepper motor in clockwise direction.