Pages: [1]   Go Down
Author Topic: Sending Rapid / Persistant Commands to a PIN  (Read 348 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I'm new to Arduino development and looking for general guidance and assistance.

I'm building a simple robot, which connects to an Arduino board for instructions, which is controlled by an Android/iOS device over WiFi.

I've opted for OSC over WiFi and I can send and receive messages from the Android device and Arduino board.

There are two types of commands I will be sending to the robot:

1 - Move for x seconds
2 - Speed (based on pressure/strength sent to a pin)

I'm planning on using the following approach:

1 - For Movement
Send a message of the following format
/[ANALOG][DIGITAL]/move/[PIN] [SECONDS]
2 - For Speed
/[ANALOG][DIGITAL]/setspeed/[PIN] [SPEED]
3 - Combined
/[ANALOG][DIGITAL]/directional/[PIN_ARRAY] [SPEED_ARRAY]
4 - For Direction Movement
/[ANALOG][DIGITAL]/directionmove/[PIN_ARRAY] [SECONDS]

where:
ANALOG = use analog signal (which I understand has a range of 0-1023)
DIGITAL = use digital signal (which I understand is either on/off, high/low)
PIN = the pin to signal (sent output to)
SECONDS = after x seconds stop output to the pin
SPEED = a value in the range 0 to 1023
PIN_ARRAY = an array of pins to send output to
SPEED_ARRAY = an array of analog values to use in conjunction with PIN_ARRAY
move = move instruction
setspeed = set the speed instruction
directional = set move/speed instruction
directionmove = move in direction for x seconds instruction

(NOTE: The range 0-1023 above is Analog range, this could also be PVM range 0-255)

I'm hoping this is enough to control the capabilities of the robot.

Areas of confusion:
1 - I'm guessing "input" from pins will always be Analog (although these pins can function as Digital input/output)
2 - Are "Output" pins always "Digital"? For instance pin 13 for the LED, I seem to only be able to set it to HGH/LOW
3 - There are Digital pins which accept PVM Output (is this the same as Analog or do we specify a value between 0 and 255)
4 - Using SoftPWM (http://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation) I was able to dim the LED (pin 13) on and off
5 - I've not used it yet, but I guess certain pins can act as Servo Outputs, which I guess is a way to send an Analog output signal (and could be used for speed control)

Questions and assistance please:
1 - How do I identify which pins are analog, digital or both
2 - How do I identify which pins are input, output or both
3 - I can use SoftPWM for the LED, however which PINS can I send an Analog signal to and is the following code how I would do this:
    pinMode(analogInputToDigitalPin(pin), OUTPUT);
    digitalWrite(analogInputToDigitalPin(pin), 300); //is there an analogWrite and should the range be 0-1023, 0-255, ...?
4 - I have an Arduino Uno R2 and Arduino ADK R3
5 - As I'm planning on offering a remote control on an iOS/Android device, are there any open source projects similar to touchOSC (http://hexler.net/software/touchosc). touchOSC is awesome, but they don't offer a plugin module for iOS/Android, and I'd like the app to have additional features (e.g. a tutorial on how the robot works and how to build it)

Thanks in advance to anyone who feeds back.

Parms
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46224
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
where:
ANALOG = use analog signal (which I understand has a range of 0-1023)
The analogRead() function returns a value in the range 0 to 1023. The analogWrite() that writes to a PWM pin takes a value in the range 0 to 255.

Quote
1 - I'm guessing "input" from pins will always be Analog (although these pins can function as Digital input/output)
Which pins? The analog pins will return a value between 0 and 1023. The digital pins will return a value between 0 and 1. Actually, the digital pin value is not "in that range". It is at one end or the other.

Quote
2 - Are "Output" pins always "Digital"? For instance pin 13 for the LED, I seem to only be able to set it to HGH/LOW
Yes. The analog pins are input only. They can be used for output, but only HIGH or LOW.

Some pins, labeled as PWM pins, can be turned on and off very rapidly, making some things connected to them think that the voltage is somewhere between 0 and 5, depending on the duty cycle.

Quote
3 - There are Digital pins which accept PVM Output (is this the same as Analog or do we specify a value between 0 and 255)
That's PWM. You specify a value for the duty cycle between 0 and 255.

Quote
5 - I've not used it yet, but I guess certain pins can act as Servo Outputs, which I guess is a way to send an Analog output signal (and could be used for speed control)
All of them can.

Quote
1 - How do I identify which pins are analog, digital or both
On which Arduino?  For the most part, they are clearly labeled.

Quote
2 - How do I identify which pins are input, output or both
Use the pinMode() function to define the direction. There is no both. The pins are all either input or output.

Quote
3 - I can use SoftPWM for the LED, however which PINS can I send an Analog signal to and is the following code how I would do this:
    pinMode(analogInputToDigitalPin(pin), OUTPUT);
    digitalWrite(analogInputToDigitalPin(pin), 300); //is there an analogWrite and should the range be 0-1023,
No, that is not the correct code. The input to both functions is just the pin number. The digitalWrite() function's 2nd argument is either HIGH or LOW, not 300.

Quote
4 - I have an Arduino Uno R2 and Arduino ADK R3
Is that a question?

Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 25
Posts: 1876
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What do you mean by "servo". Are you going to be using motors? If so what kind, DC,AC,Stepper.......? What are the servos for? A normal servo moves backward and forward in a 180 degree arc.

Mark
Logged

Pages: [1]   Go Up
Jump to: