please help me i want a program in which i need to vary the frequency of ultrasonic sensor from the output of proximity or light sensor
is this possible
char txt[6];
#define TRIG PORTB.F6
#define ECHO PORTB.F7
// LCD module connections
sbit LCD_RS at RA1_bit;
sbit LCD_EN at RA3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISA1_bit;
sbit LCD_EN_Direction at TRISA3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections
double distance;
void main() {
INTCON = 0x00; //turn off interrupts
ADRESH = 0x00;
ADRESL = 0x00;
ADCON1 = 0x06; //all inputs are digital
ADCON0 = 0x00;
ADCON1 = 0x06; //all inputs are digital
ADCON0 = 0x00;
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
TRISD = 0x00; //PORTD is output
PORTD = 0x00;
TRISA = 0x00;
PORTA = 0x00;
porta.f2=0;
Lcd_Init(); //Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
PORTA.F2=0;
TRISB.F6 = 0;
TRISB.F7 = 1;
OPTION_REG.T0CS = 0;
OPTION_REG.PSA = 0;
OPTION_REG.PS0 = 1;
OPTION_REG.PS1 = 1;
OPTION_REG.PS2 = 1;
while(1){
TRIG = 0;
delay_us(10);
TRIG = 1;
delay_us(10);
TRIG = 0;
while(ECHO==0);
TMR0=0;
while(ECHO==1);
distance = (double)TMR0 * 4.352;
wordtostr(distance,txt);
lcd_out(1,6,txt) ;
Delay_ms(500);
Lcd_Cmd(_LCD_CLEAR); // Clear display
}
}