cheerio
Newbie level 6
- Joined
- Nov 18, 2012
- Messages
- 14
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,373
What the...?? that's no algorithm, not even a little bit. Cheerio, you have no programming knowledge/experience, right? Then I assume you're *not* pretending someone to do the whole job but someone to put a pen in your hand and give you some paper... right?
Here's some help for starting...
whatever the ultrasonic sensor is the big steps are not really the ones you described. By fast examining your problem steps should be: send pulse to the sonar > start checking for the echo return > when echo arrives start buzzing > when echo ends stop buzzing. It should not be such a difficult task... You can use the RB0 pin as external interrupt and connect it to the echo pin of the ultrasonic sensor. When interrupt on RB0 is triggered you know there is echo so you start counting. When there's no more echo you check the count (probably you'd need some calculations) and you've got the distance of the object.
If you confirm my suppositions then you'll probably get helped better. Otherwise, people will keep asking which are your difficulties in programming assuming you have at least some programming knowledge.
p.s.
The ultrasonic sensor you're using is this one?
http://www.e-gizmo.com/KIT/images/ultrasonicsonar/ultrasonic sonar module 1r0.pdf
actually, i cant afford to buy gizduino right now. i know it's already the economically friendly version of the arduino but still im kinda short of penny. life's hard, you know. so, i kind of decided to use pic16f84a.
From your previous posts, I think you will turn the buzzer on as long as the obstacle is within the sensor's range (2cm to 350cm). You don't need to actually calculate the range. Or do you?
The other thing I need to know is, how frequently are you going to check if obstacle is within sensor's range. Or will it be done continuously?
sbit TRIGGER at RB2_bit;
sbit BUZZER at RB7_bit;
void main() {
PORTA = 0;
TRISA = 0;
PORTB = 0;
TRISB = 1; //RB0 input for EXTERNAL INTERRUPT
INTF_bit = 0;
OPTION_REG = 0xC0; //RBPU disabled, rising edge interrupt
while (1){
TRIGGER = 1;
delay_us(6);
TRIGGER = 0;
delay_ms(100);
if (INTF_bit == 1){
BUZZER = 1;
INTF_bit = 0;
}
else{
BUZZER = 0;
}
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?