This is the wiring scheme and it doesn't let me post another pic to show you how the whole model should look. I'm still new to all this since I started learning about arduino 2 months ago.
Well that's the issue we never did something more complicated from a stop light and I'v been learning how to code thrue youtube. Especially now when we have online classes we don't even get to experience it outside of tinkercad. so I'm basically stuck at the beginning.
Very good to provide a picture of how the device is looking like.
The screenshot shows that you are using tinkercad.
Do you have access to the real hardware?
If you can use Tinkercad this means you have at least a computer.
So you could install the Arduino-IDE and work on the code until the code does compile.
There are a couple things you should do to improve your code.
All and every variable should have a self-explaining name.
"servo" and "servo1" is not really self-explaining
You have two ultrasonsic sensors one looking more to the right one looking more to the left. So their names should be sensor_left and sensor_right
to clearly say what they are.
Developing a program works different from trying to solve all exercises of an examination.
Your code shows a collection of some basic commands that have to do with sensors and servos. But this code is far from working.
In developing programs you start with a small part. Just a real small part.
Especially at the beginning.
I have never done something with the tinkercad-arduino-simulator
So if you take a small testprogram that just moves a single servo left / right
does the tinkercad show how the servo moves?
Is the tinkercad-simulator able to simulate obstacles in different distances to the sensor?
With which part of the functionality would you like to start?
a.) Switching on/off an IO-pin at different frequencies?
b.) Moving a servo left / right
c.) Measuring distances with an ultra-sonic-sensor?
I'm willing to help you to climb up the learning curve. But I will never write
the whole code for you.
I have an arduino and the servo the sensors will come soon. Thanks alot for the help. And tinker cad simulates distance by point(something like a radar sketch) on induvidual sensors. So 1st I'm trying to locate if the object is on the right or left side. After that it needs to pin point the center on that object and the laser changes it's angle towards the object and basically shoots. I also have a code with a for statement which can pin point the middle of an object but that one was used with an ultrasonic sensor and an IR sensor then later I found out that it's hard to do pin point with it and I didn't bother to change it I can also post it just as an refrence. Oh and the servos move in tinkercad.
Your can't trigger both sonar sensors at the same time and expect to catch both echoes. By the time you have received the first echo, the second echo will have started and you won't catch the start of it. That and the second sensor is likely to catch an echo from the first sensor.
Trigger one sensor and read the echo. Then wait 20 milliseconds to let the echoes subside before triggering the second sensor and reading that echo.
WARNING: The default timeout on pulseIn() is 1,000,000 microseconds. That is WAY more than needed. Add a third argument to set the timeout the 30000UL microseconds (30 milliseconds). This will make your sketch more responsive.
"This function works very accurately in the range 3 microseconds and up. We cannot assure that delayMicroseconds will perform precisely for smaller delay-times."
@johnwasser and @crossRoads:
I appreciate that you all want to help. I recommend to start on a lower level.
as t_h mentioned he has (yet) no idea how to start
My recommendation is to start - not with the LED-blink - but with something easier than using both ultrasonic sensors at the same time.
Turning a single servo at different speeds.
You can do this in tinkercad or with the real arduino.
If you want to do it in real: Do you have a digital multimeter to measure the current of the servo?
Do you have an extra 5V power-supply for the servo?
You shouldn't supply a servo from the Arduino-5V pin. A servo pulls too much current!.
I know there are several videos on youtube who show supplying a servo from the Arduinos 5V don't do it.
As soon as the servo gets under load even a tiny servo will pull more than 500 mA and then your Arduino-5V regulator is burned through.
If you like it I can write into every posting:
I'm not goona write the whole code for you.
I will support you in a process of learning.
So make a decision: would you like to start inside tinkercad or with your real Arduino and the servo?
best regards Stefan
Well I'd love to do it in real life but I don't have a multimometer and I could probably buy a 5v batteryif that works but I could also work on tinkercad and I'm willing to learn anything just to get to that point where I could start coding.
OK. interesting approach. hm I have to ask a little bit more about how the device works. There is one servo for left right one for up down.
If the left/right servo turns the laserpointer will the utrasonic sensors turn with the laser-pointer or are the ultrasonic sensors fixed and never move?
It turns with the laserpointer I designed it that was so it could be easier to code (atleast that was my theory) so it could pin point the centre of an object. Video how the device moves also here's a video of it.
at the moment I have a "video-teacher-teaching". I can take a look every minute to this thread and write short answers. There is a break from 12:30 to 13:30 there we can do a video-meeting with gotomeeting or I can call you on the phone to explain some basic things to get you going. First step is try to find an example that does just move a servo