Go Down

Topic: Bluetooth RC car how can i tell it to move? (Read 66 times) previous topic - next topic

kamhagh

Apr 22, 2015, 01:15 pm Last Edit: Apr 22, 2015, 03:08 pm by kamhagh
Ok i want to tell my robot to move and turn up and down turn the ultra sonic give the distance etc! but im not sure how to do it! in Python i would do something like leftmotorvalue | rightmotorvalue but im not sure ow to do it in arduino as i don't know how to split them etc, i checked websites like tutorialspoint they only covered stuff like appending etc!

and also Serial.read() returns int, im not sure how to even use the functions on them! can anyone help me?

PaulS

Quote
but in arduino as stuff are a bit limited and as Serial.read() returns int im confused!
What stuff is limited? Why does the fact that Serial.read()'s return type is int cause you heartburn?

Quote
i googled Serial arduino but most of what i found was about parseInt and println!
And the problem is?

Quote
i thought of somehow sending 2 motor values on bluetooth!(instead of telling turn or etc)
From where? In what format?

Quote
in python i would just split them
Not without having saved "them" (whatever them is) in some container that python knows how to split.

kamhagh

#2
Apr 22, 2015, 03:10 pm Last Edit: Apr 22, 2015, 03:16 pm by kamhagh

Edited the question for better understanding!

kamhagh

What stuff is limited? Why does the fact that Serial.read()'s return type is int cause you heartburn?
And the problem is?
From where? In what format?
Not without having saved "them" (whatever them is) in some container that python knows how to split.
i don't know how to do stuff with int! you know! how does a character get in an int anyway :|

PaulS

Quote
i don't know how to do stuff with int! you know! how does a character get in an int anyway :|
I'll ask a different question. Why does Serial.read() return an int, when the documentation says it reads a byte from the serial port?

The answer is that Serial.read() needs some way to say "Hey, bozo, there was nothing to read!". It can't do that in a byte, because every value in a byte is legitimate data.

So, it returns an int, so that it can send an error code. If you always use Serial.available() to determine that there is data to read, before calling Serial.read(), you could store the return value in a byte-sized variable, such as bool, uint8_t, byte, or char.

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!

Arduino
via Egeo 16
Torino, 10131
Italy