Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Plasma Caster [UPDATE]


techb's Avatar
Member
0 0

Thought I would share what I've been working on. This is still in early testing stages, but its always fun to play around with pan/tilt systems. There is a better explanation and video on my site.

Now using Ping))) for the pan servo. The tilt will be via accelerometer.

CODE:

/*
pan_tilt_sketch.pde

This is quick and dirty code to
move a servo in the direction my head moves.

=-=-hacked version of Ping))) example-=-=
Modded by Tech B.
*/

#include <Servo.h>
const int pingPin = 7;
Servo pan;

//tilt not used at the moment
Servo tilt;

//initial position
int panPos = 90;

void setup() {
  
  Serial.begin(9600);
  pan.attach(3);
  tilt.attach(12);
  tilt.write(90);
  pan.write(90);
}

//Vars for ping readings
int val;
int valfil;
long duration;

void loop()
{
  // 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
  // notice the mapped values are kind flipped _
  // this is because I have the servo flipped around.
  val = map(duration, 29*2*20, 29*2*1, 0, 180);
  
  // try to smooth the signal so the servo _
  // isn't as jittery
  valfil = val * (1.0-0.05)+ val * 0.05;
  
  // write new posistion, and delay so it can have _
  // time to move there. Play around with delay() to _
  // smooth out movement.
  pan.write(valfil);
  delay(100); 
}

ghost's Avatar
0 0

haha, nice. I have to admin that it looks a tad like a ghetto version of the Predator Shoulder Lazer gizmo.

<html> <p align="center" <img src="http://robosavvy.com/Builders/limor/predator.jpg"> </p> </html>

EDIT* sorry, forgot the above code would fail in the forum box.


techb's Avatar
Member
0 0

This is stage one. My friend is making a fiber glass version for me that will be more pleasing to the eye. I have a coil gun that will be attached to the finished version, along with a strobe flash.

If everything works out, a camera will be added running my facial recognition software.


yours31f's Avatar
Retired
10 0

That'll be awesome. Can't wait to see the final product.


stealth-'s Avatar
Ninja Extreme
0 0

Lookin' good, man. Keep us updated.


techb's Avatar
Member
0 0

I've been working on using an LCD Display shield, but I should have my HTC tomorrow, and using the HTC as a control unit instead of wearing a backpack with a running laptop in it. It will all depend if I can use a COM port on the HTC platform. I will also need to get another BT board or an XBee shield since I fried the only BT board I had.


techb's Avatar
Member
0 0

Code for the update coming shortly. I'm tired and need to go to bed.