Go Down

### Topic: Partiot missile Project (Read 1 time)previous topic - next topic

##### Dec 23, 2012, 03:37 pm
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...

I'm not crazy, I have the mental health hospital discharge papers to prove it!

#### robtillaart

#1
##### Dec 23, 2012, 04:24 pm
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
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#2
##### Dec 23, 2012, 04:31 pm
*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???
I'm not crazy, I have the mental health hospital discharge papers to prove it!

#### PaulS

#3
##### Dec 23, 2012, 04:54 pm
Quote
if(c == 0){
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.

#### robtillaart

#4
##### Dec 23, 2012, 04:56 pm
Quote
Anybody knows about an app for android for serial communication???

Over bluetooth? => Blueterm ?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#5
##### Dec 23, 2012, 06:03 pm

Quote
if(c == 0){
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??

...

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.

Quote

while (Serial.available() > 0) {

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

In my defence...
programming is not my strong point...

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

Quote
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.....
I'm not crazy, I have the mental health hospital discharge papers to prove it!

#### wizdum

#6
##### Dec 23, 2012, 06:37 pm
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.

"Anyone who isn't confused really doesn't understand the situation."

Electronic props for Airsoft, paintball, and laser tag -> www.nightscapetech.com

#### PaulS

#7
##### Dec 23, 2012, 08:18 pm
Quote
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.

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

Yes, but that is not what you have. What you have is:
Code: [Select]
`//    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.

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

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

#### GoForSmoke

#8
##### Dec 23, 2012, 09:04 pm
Cool video but gimme dat ole time religion!
See if you can get bottle rockets where you live.

Quote
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.
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

#9
##### Dec 27, 2012, 07:57 pm

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!
I'm not crazy, I have the mental health hospital discharge papers to prove it!

Go Up

Please enter a valid email to subscribe