Boa noite,
Continuando minhas aventuras com o Arduino e sensores. Hoje decidi brincar com o Sensor Ultrasonico HC-SR04 para medir distancia.
O funcionamento do mesmo é realmente simples, ele possui 4 pinos, VCC para alimentação, Trig para iniciar uma medida, Echo para retorno da distância e GND terra.
O mesmo possui uma biblioteca pronta para fazer as medidas e tudo mais. A mesma se chama Ultrasonic. O unico problema que tive com a mesma é que ela estava desatualizada e ainda utilizava o WProgram.h enquanto o Arduino 1.0.1 utiliza Arduino.h, atulizei a mesma e executei sem problemas.
A mesma deve ser incluida no seu diretório “arduino-1.0.1/libraries” e você deve fechar e abrir a IDE.
Sensor VCC conecta ao Arduino +5V pino
Sensor Trig conecta ao Arduino PINO 12
Sensor Echo conecta ao Arduino PINO 13
Sensor GND conecta ao Arduino GND
Você pode configurar os pinos nas variáveis trig e echo.
[code lang=”c”]
#include “Ultrasonic.h”
int trig = 12;
int echo = 13;
Ultrasonic ultrasonic(trig,echo);
void setup() {
Serial.begin(9600);
}
void loop()
{
Serial.print(“Distance CM:”);
Serial.println(ultrasonic.Ranging(CM));
Serial.print(“Distance INC:”);
Serial.println(ultrasonic.Ranging(INC));
delay(100);
}
[/code]
Referências:
HC-SR04 DataSheet
Biblioteca Ultrasonic atualizada para Arduino 1.0.1
Well crafted post, the structure flows naturally from one point to the next without forcing transitions, and a stop at motionwithclarity kept the same flow going, you can tell when a writer has thought about how their content reads rather than just what it contains and this is one of those examples.
Felt a small spark of recognition when the post named something I had been struggling to articulate, and a look at expertvertex produced more such moments, the rare service of giving readers language for fuzzy intuitions is one of the higher values that good writing can provide and this site offered several today instances.
Worth recognising the specific care that went into how this post ended, and a look at broadcastnova maintained the same careful conclusions, endings are where most blog content falls apart and this site has clearly invested in the closing stretches of its pieces rather than letting them simply trail off when energy fades.
Beats most of the alternatives on the topic by a noticeable margin, and a look at ideasrequiremovement did not change that at all, this is one of the better corners of the open internet for this kind of content and I am glad I clicked through rather than skipping past quickly like I usually do.