Hi Guy's,
I have a little alarm i am trying to put together that consists of a HC SRO4 distance sensor and a Piezo Buzzer. wiring this up to the arduino is straight forward and the code is fairly straight forward as can be seen below.
My Question is which pins would i connect to on an ATTiny 85 once i have programmed it with this code?
*/
#define trigPin 13
#define echoPin 12
#define buzzer 11
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 50) { // This is where the buzzer On/Off happens
digitalWrite(buzzer,HIGH);
}
else {
digitalWrite(buzzer,LOW);
(distance >= 200 || distance <= 0);}
}