That worked very well. Thanks.
- Highest Reputation Content
Highest Reputation Content
#88 Kill switch code placement
Posted by colintheraven on 31 March 2014 - 03:46 PM
#69 Trouble with Robotics kit
Posted by Nathan House on 16 March 2014 - 12:17 AM
I would definitely suggest grabbing the code from the ultrasonic sensor tutorial and trying it out. If it doesn't work with that code (which we know works), then it's a wiring issue. Sorry you're having trouble getting it to work, I know how frustrating it can be when stuff doesn't work!
do you know the distance (cm/inch) that the robot considers an object in the way at? I have to write a paper on what I learned, and that would a useful contribution I think.
Well, if you're talking about the code from the tutorial, then the robot changes states (from driving forward to turning) when it detects an object 6cm in from of it. The robot can detect objects much further away than that, but that's the point where the code in the tutorial tells the robot to "take action" and turn.
Good luck with your paper!
- 1
#67 Trouble with Robotics kit
Posted by Nathan House on 11 March 2014 - 03:12 AM
At a cursory glance, I don't see anything wrong with your code, so my guess is that it has something to do with wiring. Do you have both 5V and GND wires going to the breadboard? Your idea of just wiring up a single sensor is a good idea. Reducing the complexity of a circuit and/or program always makes it a lot easier to debug. So try your idea -- just leave one sensor hooked up and take out the code in the program for the other sensors, then see what happens.
If you can't figure out what's going wrong, you could always try using code you know works, such as from this tutorial: http://www.foxytroni...ino/programming
Let me know what happens!
- 1
#63 Trouble with Robotics kit
Posted by Nathan House on 07 March 2014 - 05:49 PM
Hey, so sorry for taking so long to get back with you! This is the last week before spring break at my school, so there have been lots of exams and stuff! I read your writeup on your website and it looks great! Nice job!
I've re-oriented the breadboard so two of the ultrasonic sensors face out, but I've run into a bit an issue with the extension cable for the forward facing one. The cord is rather long and I have no clue how to affix it to the robot! Do you have any ideas?
Are you asking how to mount the sensor to the robot, or what to do with the cable since it's so long?
If you're trying to figure out how to mount the sensor, take a look at how I did it in this video:
The sensors have mounting holes in the corners and what I did was I poked holes in the cardboard base of the robot, set the sensor on the base, then ran wire through the holes to affix the sensor to the robot. It actually was very sturdy. You could also use right-angle brackets if the wire doesn't work (they're sold at hardware stores and look like this: http://7layerstudio....7dba7970b-320wi).
As far as what to do with the cable, I would fold it back and forth over itself, use a zip tie (or wrap electrical tap around it) to keep it from unraveling, then use some tape to fix it to the robot.
If that doesn't make sense, let me know and I can post some pics..
Also, once I get this working, I'd like to add some features besides wall avoidance, just to add the cool/techy factor. Do you have any suggestions for extensions?
Well, there are lots of things you could do!
You could easily make it into a line following robot, which is a fun project, by using 5 IR sensors like these:
https://www.foxytron...-optical-sensor
You could give it the ability to drive perfectly straight by using a gyroscope (which I think are really cool!) like this:
https://www.foxytron...ometer-mpu-6050
That board actually has 3 gyroscopes and 3 accelerometers, so you can do a lot with it.
You could add a color sensor to it, like this one:
https://www.foxytron...r-sensor-module
Or you could use some photoresistors (I think there were some in your robotics kit?) to make the robot drive towards or away from light sources.
Adding an LCD to the robot is also something cool that you could do..
If you haven't been on the Arduino forum, be sure to check it out at forum.arduino.cc. I'm sure people could give you a ton of suggestions for projects on there!
Also, if I don't have the parts you need, be sure to checkout https://www.sparkfun.com/. They're a much bigger company and have a lot more sensors and parts than me (for now!).
- 1
#247 modifying funduino robot code for project.
Posted by Si_Price on 16 March 2015 - 04:54 PM
You mean the distance at which it changes from the drive forward to the turn left state? That would be this code:
if(ultrasonic2Distance > 0 && ultrasonic2Distance < 6) { // there's an object in front of usThat code is saying to go into the IF statement if the distance measured is 6. Making that number smaller means the robot will have to get closer to the object before branching, making the number larger means it will branch sooner.
Ah okay thanks, I tried increasing it but my robot still manages to flip himself sometimes, I think it's because of the angle he approaches the wall and the radius of the distance sensor only reading from the front. I have managed to implement the flashing LED and the stop sequence though so that's something! thanks
- 1
#229 ArduinoRobot
Posted by Nathan House on 10 March 2015 - 02:00 PM
No problem, glad you are trying to understand it!
timeSerialdelay and timeLoopdelay have an initial value of zero, but then their values are changing later in the program.
Inside of the IF statement in loop(), you can see that we set timeLoopDelay = millis(), where millis() is the number of milliseconds the Arduino has been powered on for. Initially, timeLoopDelay is zero, as you noticed. In the conditional statement (IF statement) we check that millis() - timeLoopDelay >= loopPeriod. In other words, we check to see if looPeriod milliseconds has elapsed since the last time the code in the loop was executed. We do this to make the code inside the loop only run every loopPeriod milliseconds, instead of running much more frequently.
The timeSerialDelay variable is used similarly, to only print information out to the serial terminal every quarter second instead of constantly printing it out (which makes it impossible to read).
- 1
#222 Can the robot run on 4 AA batteries?
Posted by Nathan House on 06 March 2015 - 12:14 AM
Nope, it won't work with 4 AA batteries. The reason is that the Arduino requires an input voltage of 7-12V to operate reliably. 4 AA batteries (non-rechargeable) would only provide 6V, while rechargeable batteries would provide even less (1.2V per cell instead of 1.5V).
- 1
#17 First Feedback
Posted by jpooda on 21 October 2013 - 02:21 AM
I was just clicking through the forums and realized that there was no posts on your feedback forum, so I decided to change that. Well first of all, I love your website and your catalog of products. Your extremely fast at shipping and compared to Adafruit, you were one day faster then them. I found FoxyTronics through Chief Delphi a while back, since I am on FIRST robotics, like you were. (team 1986 to be exact) So I am a permanent customer for you and I will always comeback if your catalog has the product i'm looking for. One thing though, I ordered an arduino from you a while ago, and it was a legit arduino. When I ordered another one a month ago, I realized you switched to an off-brand arduino, will you ever switch back? All in all, love your business and keep up on adding to your catalog!
~Jay Urban
- 1
#159 Problem With My Robot
Posted by Nathan House on 21 October 2014 - 02:37 AM
Oh snap! I know what the problem is! Your servos must somehow be in a different orientation than in the tutorial.
Change this:
// drive forward rightMotor.write(180); leftMotor.write(0);
To this:
// drive forward rightMotor.write(180); leftMotor.write(180);
And this:
// turn left rightMotor.write(180); leftMotor.write(180);
To this:
// turn left rightMotor.write(0); leftMotor.write(180);
- 1
#147 Problem With My Robot
Posted by Nathan House on 20 October 2014 - 11:26 PM
Alright, so that means the servos are wired correctly. The next thing I want you to test is the ultrasonic sensor. Here's code from the page I linked to before:
const int serialPeriod = 250; // only print to the serial console every 1/4 second unsigned long timeSerialDelay = 0; const int loopPeriod = 20; // a period of 20ms = a frequency of 50Hz unsigned long timeLoopDelay = 0; // specify the trig & echo pins used for the ultrasonic sensors const int ultrasonic2TrigPin = 8; const int ultrasonic2EchoPin = 9; int ultrasonic2Distance; int ultrasonic2Duration; void setup() { Serial.begin(9600); // ultrasonic sensor pin configurations pinMode(ultrasonic2TrigPin, OUTPUT); pinMode(ultrasonic2EchoPin, INPUT); } void loop() { debugOutput(); // prints debugging messages to the serial console if(millis() - timeLoopDelay >= loopPeriod) { readUltrasonicSensors(); // read and store the measured distances timeLoopDelay = millis(); } } void readUltrasonicSensors() { // ultrasonic 2 digitalWrite(ultrasonic2TrigPin, HIGH); delayMicroseconds(10); // must keep the trig pin high for at least 10us digitalWrite(ultrasonic2TrigPin, LOW); ultrasonic2Duration = pulseIn(ultrasonic2EchoPin, HIGH); ultrasonic2Distance = (ultrasonic2Duration/2)/29; } void debugOutput() { if((millis() - timeSerialDelay) > serialPeriod) { Serial.print("ultrasonic2Distance: "); Serial.print(ultrasonic2Distance); Serial.print("cm: "); Serial.println(); timeSerialDelay = millis(); } }
Upload the code, then open the serial monitor in the Arduino IDE and see what prints out when you move something back and forth in front of it. It should print out the distance.
- 1
#145 Problem With My Robot
Posted by Nathan House on 20 October 2014 - 10:59 PM
Hey Rider,
Sorry for not getting back with you sooner. I've been sick the past couple of days :-(
That's a cool looking robot!
Added a separate battery pack because when I Split the pack something was causing my Ardiono To get to hot.
Something was probably wired incorrectly if the Arduino was getting hot, but using a separate battery pack is better anyway.
Well I have it built and It is doing the exact opposite of what it should do (Drive Forward until it detects an object then turn) Well At the moment its turning right and going straight when it detects something. I have used the Exact code in your Tutorial and built it pretty much the same. Yet I cant find out why its doing this. Do you have any ideas why?
So when the robot is supposed to drive straight, it turns, and when it's supposed to turn, it drives straight..
Since you're using the exact code from the tutorial, there must be something different with your wiring. Let's try to debug the problem!
When you're trying to debug a problem like this, the best thing to do is break it down into smaller steps to make the debugging easier. So let's start by trying to make the robot drive straight. If you look on the tutorial page, you can find this code:
#include <Servo.h> // create servo objects Servo leftMotor; Servo rightMotor; void setup() { leftMotor.attach(13); rightMotor.attach(12); } void loop() { leftMotor.write(180); rightMotor.write(180); }
Try uploading that to your Arduino and see if it drives forward (or backward). If not, then we can try to figure out why it's not driving straight. If it does drive straight, then we know this part works and can move on to trying something else. The key is to break the problem down into sub-problems and attack them one at a time.
Good luck, and let me know how it goes!
- 1
#255 Increasing Ultrasonic Sensor Range?
Posted by EinsteinMC on 26 April 2015 - 07:54 PM
How can i modify the code in order to allow the sensor to detect an obstacle that is further away? Basically, I want the sensor to detect obstacles earlier and therefore have the robot respond earlier.
EDIT: Forget it, I got it. Had to increase the value in the if statement
if(ultrasonic2Distance > 20 || ultrasonic2Distance < 0) {}
- 1
- Highest Reputation Content