Partiot missile Project

Hiya!
Ever seen a Patriot missile in C&C Genarals?
(Apperently they actually exist... 0_0)


I made something like that, but with an ADFruit LED strip.(Didn't want to kill someone...)

Basicly it communicates to the computer by serial, recieving info like bullet velocity, direction of fire esc., and using Trajectory calculations to calculate the amount of degrees that it should aim to hit the target...

Problem is it only promps the first line. ie "Enter Password:"
Thus I cant see if my calculations are correct...

could someone maby take a look at my code?

Here is a video

Note: my coding isn't very neat...

Thanx in advance!

SO1_1.ino (4.07 KB)

it is really funny @ 0:45 when you shoot the patriots right up ... think the real one has some safety for that trajectory
Also the speed of firing explains why the defence budget is so BIG :wink:

ROFL
HAHA!
The project started out as something like THIS

but my father said it looks like a "Starlien orrel" (The South African version of something like an Patriot Missile)

So... This was born....

Any thoughts on the code....

PS... I would like to make it wirelesly controlled by bluetooth...

Anybody knows about an app for android for serial communication???

if(c == 0){
pass = Serial.read();
if(pass == 1024){

Would you kindly explain how you intend to enter the character who's ASCII value is 1024 in the Serial Monitor?

While you are at it, kindly explain why you are not checking for there actually being data to read before you try to read it.

Anybody knows about an app for android for serial communication???

Over bluetooth? => Blueterm ?

PaulS:

if(c == 0){
pass = Serial.read();
if(pass == 1024){

Would you kindly explain how you intend to enter the character who's ASCII value is 1024 in the Serial Monitor?

Ok... So, what you are saying is that I'm trying to read ASCII Characters instead of Integers??
And that I should put quotes around the 1024??

...

PaulS:
While you are at it, kindly explain why you are not checking for there actually being data to read before you try to read it.

while (Serial.available() > 0) {

isn't that checking if there is data available??

In my defence...
Everything I know about this stuff I taught myself....
programming is not my strong point...

PS... Isn't this supposed to be a place where I can ask for help??

robtillaart:

Anybody knows about an app for android for serial communication???

Over bluetooth? => Blueterm ?

Thanx Any tips on connecting that to an iTead bluetooth Shield??
It didn't work last time I tried.....

Firstly, I would like to formally welcome ECHELON to this thread...

Theres a few Patriots at an old military base near my house, old military tech is pretty cool. It cost so much to ship everything out, that they just left most of the stuff where it sat. There's still vehicles on the tarmac and fire trucks in the garage, desks still have non-classified papers on them.

Also, your avatar is awesome.

Ok... So, what you are saying is that I'm trying to read ASCII Characters instead of Integers??
And that I should put quotes around the 1024??

I was asking you how you are sending the data to the Arduino. If it is via the Serial Monitor, then it arrives at the Arduino as ASCII data - one character at a time. "1024" is NOT one character. '1024' is, but you can't send that value via the Serial Monitor.

isn't that checking if there is data available??

Yes, but that is not what you have. What you have is:

//    while(Serial.available() > 0);{

The wait for there to be serial data to read statement is commented out. That { is not needed, and, even it it was shouldnotbejammedupagainstthestatementlikethat.

Isn't this supposed to be a place where I can ask for help??

It is. Didn't I make some effort to try?

Cool video but gimme dat ole time religion!

See if you can get bottle rockets where you live.

And that I should put quotes around the 1024??

You would read "1024" as 4 separate characters. Each digit comes in s-l-o-w-l-y compared to Arduino speed. You need to check that all the digits come in (perhaps at least 1) and that not too many digits come in (at most 4?) and that a separator byte follows the digits (maybe a comma or linefeed or space, you decide) and that nothing but digits and separator come in (because the world is not perfect, errors happen).

You can read the characters into a char array (C string please, not C++ String!) and add a terminating zero then use atoi() to turn that into a number or.....
You can set an int to zero and as you get each digit (checking limits, etc as above) multiply the int x 10 then add the ASCII digit you read minus '0' (so '0' - '0' = 0 to '9' - '0' = 9).

How it works:

byte digit; // I will read serial bytes into this
int total = 0; // I will build the result in this

// I read '1' from serial into digit
total *= 10; // multiplies total * 10 and stores that into total, first time is 0 x 10 = 0
total += digit - '0'; // total now = 1

// I loop around, checking for digits and not over-length and with the rest, "024" total becomes;
// 1 x 10 + '0' - '0' = 10 + 0 = 10
// 10 x 10 + '2' - '0' = 100 + 2 = 102
// 102 x 10 + '4' - '0' = 1020 + 4 = 1024

If I read the separator after 1 or more digits I leave the loop and my result is in total.
If anything is wrong, I leave the loop with a variable set indicating error and result is bad.

Is that enough for you to code with? You can go either way.

For me, code is like the old puzzle games we had before hand calculators and PC's were around.
It can be a lot of fun and challenge, but once you add deadlines the fun and games are over.

Thanx for all your help...

I'll gain some more knowledge on serial communications before continuing this project.
I tried to sprint before I could run...

You were all a huge help!