const int pingPin = 7; const int red=11; const int blue=10; int green=9; void setup() { // initialize serial communication: Serial.begin(9600); pinMode(red,OUTPUT); pinMode(blue,OUTPUT); pinMode(green,OUTPUT); } void loop() { // establish variables for duration of the ping, and the distance result // in inches and centimeters: long duration, inches, cm; // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW); // The same pin is used to read the signal from the PING))): a HIGH pulse // whose duration is the time (in microseconds) from the sending of the ping // to the reception of its echo off of an object. pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH); // convert the time into a distance inches = microsecondsToInches(duration); cm = microsecondsToCentimeters(duration); Serial.print(inches); Serial.print("in, "); Serial.print(cm); Serial.print("cm"); Serial.println(); if(inches10 && inches
@@domingomartinez1536 can u help me with my school problems? My ICT teacher wants us to make led green blink if under 90cm and led brown will blink if the distance is 40cm using the hc sensor... Pleaze your my only hope.
Great video but I am confused. All of my ultrasonic sensors (hc-sr04) has 4 pins. 1 for gnd, 1 for vcc, 1 for trig and 1 for echo. Is there a way to change the ultrasonic sensor ? All I see is the one u used in this video and that sensor isn't suitable for my project since I don't have the same sensor. Could you help me please?
const int pingPin = 7; const int red=11; const int blue=10; int green=9; void setup() { // initialize serial communication: Serial.begin(9600); pinMode(red,OUTPUT); pinMode(blue,OUTPUT); pinMode(green,OUTPUT); } void loop() { // establish variables for duration of the ping, and the distance result // in inches and centimeters: long duration, inches, cm; // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: pinMode(pingPin, OUTPUT); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW); // The same pin is used to read the signal from the PING))): a HIGH pulse // whose duration is the time (in microseconds) from the sending of the ping // to the reception of its echo off of an object. pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH); // convert the time into a distance inches = microsecondsToInches(duration); cm = microsecondsToCentimeters(duration); Serial.print(inches); Serial.print("in, "); Serial.print(cm); Serial.print("cm"); Serial.println(); if(inches10 && inches
You have saved my life young man
Hi there. Thank you very much for your time and effort to show us this kind of projects. Very useful.
Thanks for the great video on this.
const int pingPin = 7;
const int red=11;
const int blue=10;
int green=9;
void setup() {
// initialize serial communication:
Serial.begin(9600);
pinMode(red,OUTPUT);
pinMode(blue,OUTPUT);
pinMode(green,OUTPUT);
}
void loop() {
// establish variables for duration of the ping, and the distance result
// in inches and centimeters:
long duration, inches, cm;
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
// The same pin is used to read the signal from the PING))): a HIGH pulse
// whose duration is the time (in microseconds) from the sending of the ping
// to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
if(inches10 && inches
thanks for this this really helped me out!
Thank you for the help. Appreciate it. 👍
It is a very good video
Thank you very much
The LED blinks Green even if the object is beyond the range of the sensor.What changes should i make in the code?
Add an else statement at the end and light up any 2 LEDs to make a custom color
Please give space between operator and variable . I don't know why but i feel uneasy when somebody does that
Can you show programming in blocks?
What sensors or outputs do you want me to control?
My new video uses block programming
Can you do 1 with the hc sensor?
Its in the description
@@domingomartinez1536 can u help me with my school problems? My ICT teacher wants us to make led green blink if under 90cm and led brown will blink if the distance is 40cm using the hc sensor... Pleaze your my only hope.
@@domingomartinez1536 notice
@@domingomartinez1536 notice please
@@domingomartinez1536 not me
Bro I can understand the lag and the fans running in the bg because I have a 10 yr old laptop
Great video but I am confused. All of my ultrasonic sensors (hc-sr04) has 4 pins. 1 for gnd, 1 for vcc, 1 for trig and 1 for echo. Is there a way to change the ultrasonic sensor ? All I see is the one u used in this video and that sensor isn't suitable for my project since I don't have the same sensor. Could you help me please?
here it is with code: www.tinkercad.com/things/k9eioRZ9ofs-ultrason-hc-sr04
Which resistance did u used?
220 Ohm resistor
what is this software
hello,
please tell me how to add sound sensor in tinkercad
i am not able to find sound sensor in tinkercad
You can add a buzzer (Piezo) from the components, and vary its frequency in the code to make the beep sound
code pls
www.tinkercad.com/things/coFS7RHB0l4
alguem traduz ou me explica porfavor
Can you make the code somewhere to copy?
You can search the code in google
I put the code in the description
@@domingomartinez1536 a bit late 😇
@@notanoption1793 my bad lol
const int pingPin = 7;
const int red=11;
const int blue=10;
int green=9;
void setup() {
// initialize serial communication:
Serial.begin(9600);
pinMode(red,OUTPUT);
pinMode(blue,OUTPUT);
pinMode(green,OUTPUT);
}
void loop() {
// establish variables for duration of the ping, and the distance result
// in inches and centimeters:
long duration, inches, cm;
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
// The same pin is used to read the signal from the PING))): a HIGH pulse
// whose duration is the time (in microseconds) from the sending of the ping
// to the reception of its echo off of an object.
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
// convert the time into a distance
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
if(inches10 && inches
arduino 1.8.5