Author Options:

Analog and Digital inputs over serial? Answered

good day,

question i am building a controller for my robot and i need to send the inputs(analog/digital) by xbee to my robot.
now i am not good with programming i get stuck with the first line....

i want to know how i can program it to send it values over serial from xbee tot xbee on robot

i didn't get anything work so far, maybe you guys cant help me with a start?

Inputs -> arduino -> serial -> Xbee -> Xbee(receiver) -> arduino -> outputs(servo, lights, motors, steppenmotors)

the inputs on the controller are 8 switches(digital) and 6 analoge joysticks!

Prototype robot is pictured on the picture
it had for now a arduino relay shield to control the motors but it will be change to a motor controller(I don't have one yet) any type is possible!


The forums are retiring in 2021 and are now closed for new topics and comments.

4 years ago

If I may suggest use that separate character 'X' followed by 0000 to 4096 is a 12 bit representation of your analog joystick to differentiate between analog data and digital data then use.

'A' for SW1=ON and 'a' for SW1=off

'B' for SW2=ON and 'b' for SW2=off

'C' for SW3=ON and 'c' for SW3=off

'D' for SW4=ON and 'd' for SW4=off

'E' for SW5=ON and 'e' for SW5=off

'F' for SW6=ON and 'f' for SW6=off

'G' for SW7=ON and 'g' for SW7=off

'H' for SW8=ON and 'h' for SW8=off

'J' for ALL-SW=ON and 'j' for ALL-SW=off

'j' is a powerful feature that may prove useful at Power_ON

You will need to use a 12 bit ADC that gives 4096 positions ,or less,

ADC = (Analog_to_Digital_Converter) for each pot... Most microprocessors have built in two 8_bit ADC that only resolves a pot to 256 positions you must decide for yourself...

Also, I would only send the data that has changed...


4 years ago

1. Stop trying to do the complicated and get something simple working.

2. Get the xbees talking to each other. you will need a micro processor at each end.

3. You may get more direct help from either Arduino or Xbee forums.

Always start by getting the parts of the project to work then stitch them together. That way you stand a chance of success. Once the link works then your going to be sending a series of numbers over Depending on how you treat them depends on what happens, You can for example write each number to a variable which then sets some action eg steering or speed.

You could separate the numbers with a character to indicate start and stop of each number group i.e have the receiving micro processor look for character X the information to the next X is your data.

The key is to always send the same data stream even if the data hasn't changed so nothing gets confused.



Answer 4 years ago


While it is nice to think about putting parts together and start by directing action robot action... Rick is correct make a link work as a first step.