BOA TARDE, SOU INICIANTE EM ARDUINO E TO COM UMA DUVIDA, SE ALGUEM PUDEER ME AJUDAR AGRADEÇO..

TO COM UM PROJETO PRA GINCANA DO COLEGIO QUE VI NA INTERNET, UM BASTAO PRA CEGOS QUE AO DETECTAR OBSTACULOS ELE VIBRA,

NO PROJETO EU USO SENSOR ULTRASSONICO, ARDUINO E 2 VIBRACALL, JA CONSEGUI FAZE-LO VIBRAR COM OS VIBRACALL, AGORA QUERO INCREMENTAR COM BUZZER, COMO POSSO FAZER  COM QUE O BUZZER SOE UM ALARME JUNTO COM OS VIBRACALL NESSE CODIGO ? OBRIGADO

const int trigPin = 12;
const int echoPin = 13;
const int motorPin = 5;
const int motor2Pin = 6;
const int limitCm = 30;

int distancia;

void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(motorPin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
}

void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

digitalWrite(trigPin, HIGH);
delayMicroseconds(10);

digitalWrite(trigPin, LOW);

unsigned long duracao = pulseIn(echoPin, HIGH);
distancia = duracao / 58;

Serial.print("Distancia em CM: ");
Serial.print(distancia);
Serial.println("cm");

checkLimit();
delay( 1000 );
}

void checkLimit() {
if ( distancia < limitCm ) {
digitalWrite( motorPin, HIGH);
digitalWrite( motor2Pin, HIGH);
Serial.println( "ALERTA!...");
} else {
digitalWrite( motorPin, LOW);
}
}

Exibições: 708

Responder esta

Respostas a este tópico

Oi RS, boa tarde.
Ligue um buzzer que tenha oscilador interno em paralelo com o vibracall.
Nem precisa alterar o code.
Exemplo: http://www.soldafria.com.br/buzzer-12mm-com-oscilador-interno-12v-p...
Rui

No momento não tenho como comprar esse, tem algum lugar que eu possa retirar um desses? o buzzer que tenho aqui tirei de uma placa mae de computador velha, quando ligo em paralelo ele so da um tic e para

Oi RS,

este buzzer que voe está usando é sem oscilador interno.

Experimente este code com ele.

http://pastebin.com/scyNY8vR

Rui

Me salvou, funcionou perfeitamente, muito obrigado

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço