I'm making a project where the LEDs turn one the farther away something is from the sensor, and when it's really close the LEDs are off and the buzzer is on. Also two lights on the Uno are constantly on when plugged in, it's the ON and L lights. And they're red, how do I fix this. This is the site I mostly used to make it:
https://create.arduino.cc/projecthub/brillianttechnoz/led-distance-measurement-using-ultrasonic-sensor-and-aurdino-4480f6
It worked when I tried it in school a couple of days ago and it worked, but now I'm trying it again at home somethings gone wrong. I'm not sure what distance is used when the code is like this, does 20 mean 20 cm or 20 mm? This is the code I'm using:
int trig = 10;
int echo = 11;
int led1 = 6;
int led2 = 7;
int led3 = 8;
int buzz = 5;
void setup() {
// put your setup code here, to run once:
pinMode(10, OUTPUT);
pinMode(11, INPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
long duration, distance;
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
duration = pulseIn(echo, HIGH);
distance = (duration / 2) / 29.1;
if (distance < 20)
{
digitalWrite(buzz, HIGH);
}
else
{
digitalWrite(buzz, LOW);
}
if (distance < 40)
{
digitalWrite(led1, HIGH);
}
else
{
digitalWrite(led1, LOW);
}
if (distance < 60)
{
digitalWrite(led2, HIGH);
}
else
{
digitalWrite(led2, LOW);
}
if (distance < 80)
{
digitalWrite(led3, HIGH);
}
else
{
digitalWrite(led3, LOW);
}
}
The LEDs don't turn on correctly (the red and green are on, or the yellow is on, as seen in the pictures later on), the buzzer doesn't work at all, but the strangest thing is that the port is COM1. And this is the error:
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM1
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x2b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x2b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x2b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x2b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x2b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x2b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x2b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x2b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x2b
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x2b
avrdude done. Thank you.
Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
I've searched on google and I've read some stuff that might help, but I don't know how to do it. It mentions this site and drivers, which I 99% sure is the problem, but I don't know what I need to do. And I also don't want to just try anything since I'll probably make things worse. How do I install the drivers? I'm sorry if I'm being really dumb (which I am).
This is the schematic, the resistors are 100 ohms, and I'm not sure if that0s the buzzer I'm using but I'm 100% sure I connected the buzzer correctly. There are also pictures of it.