Go Down

Topic: roaming tank (Read 1 time) previous topic - next topic


OK so i am kind of new to this ,
so far i have constructed the tank in the pic below
Audrino mega
motor shield (added heat sync)
4 ping (parallax)
2 motors (3V i think)

I looked over several sketches for Wandering with ping but still confused on how to modify for current hardware


What needs to be modified?


I can  get it  to  spit out  ranges  from the sensors
however i  am unsure of how to  get  it  to  change directions based on ranges
or is it that i should us  IF statements?


Nov 12, 2012, 03:51 am Last Edit: Nov 12, 2012, 03:55 am by codlink Reason: 1

I can  get it  to  spit out  ranges  from the sensors
however i  am unsure of how to  get  it  to  change directions based on ranges
or is it that i should us  IF statements?

"if" statements are the easiest way.  Take a look at a sketch that I did with Ping sensor and servos.

I also recommend the "NewPing" library.

Code: [Select]
#include <Servo.h>

#define trigPin 8
#define echoPin 9
Servo righteyelid;
Servo lefteyelid;
int pos = 0;

void setup() {
 Serial.begin (9600);

void loop() {
 int duration, distance;
 digitalWrite(trigPin, HIGH);
 digitalWrite(trigPin, LOW);
 duration = pulseIn(echoPin, HIGH);
 distance = (duration/2) / 29.1;
 if (distance <= 10)
   Serial.println("servo on");
 else {
   Serial.println(" cm");

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131