After failing to set up a couple of digital sensors I decided to test the digital IO on the control board of the "Arduino Robot". (I am evaluating this as a platform for our school). I composed a simple blink program and tested all the DIO pins: D4 and D5 work as expected but D0-D3 do not do anything.
#include <ArduinoRobot.h>
#include <Wire.h>
#include <SPI.h>
#include <Streaming.h>
//#define LED_PIN D5 // This works for input and output.
//#define LED_PIN D4 // This works for input and output.
//#define LED_PIN D3 // Nothing works
//#define LED_PIN D2 // DOUT doesn't work but DIN does
//#define LED_PIN D1 // DOUT doesn't work but DIN does
//#define LED_PIN D0 // DOUT doesn't work but DIN does
#define LED_PIN D3
boolean ledState = LOW;
void setup() {
Robot.begin(); // Not necessary for what we are doing.
pinMode( LED_PIN, OUTPUT );
// pinMode( LED_PIN, INPUT ); // For input testing
Serial.begin(9600);
}
void loop() {
Robot.digitalWrite( LED_PIN, ledState );
//
// Robot.digitalWrite( D5, digitalRead( LED_PIN ) ); // Tests the input capability of LED_PIN
ledState = ! ledState;
delay(500);
}
// For D4 which can take analogWrite.
void pulse() {
for (int x = 0; x < 256; x++) {
Robot.analogWrite(D4, x); //increase brightness of an LED on TK0
delay(5);
}
for (int x = 255; x > 0; --x) {
Robot.analogWrite(D4, x); //increase brightness of an LED on TK0
delay(5);
}
}
Is this simply a defective device or is there some mystery not yet solved about this arrangement. I note that others have found the DIO pins to be a bit squirrelly.
On most Arduinos, D0 and D1 are the hardware serial pins. Perhaps the robot is using these pins already. D2 and D3 are external interrupt pins. Perhaps the robot is using these pins already.
Thank you. That may, indeed be the problem. The documentation is a bit sketchy on these details (no one location for details). For example, in the code, D4 is incapable of PWM but there are on-line examples of this being used as such. Indeed, I have successfully tested this feature. The robot code reference indicates that D0-D5 can all be used for digitalRead and digitalWrite at any time.
Just to be clear D0-D3 (TKD0-TKD3) are not hardware mapped to the D0-D3 pins on the 32U4 chip. Are you sure they are connected to the transmission and interrupt pins? They, like the M0-M7 pins (TK0-TK7), are connected through a MUX switch and may not be connected to the same pins designated in an UNO or Leonardo. For example, as indicated in the code, you cannot make a call to digitalOut but must make a call to Robot.digitalOut which handles the requests through a dispatcher.
To be sure, another big problem in the documentation is that the control board of the "Arduino Robot" (a prebuilt package) has on it's silk screen different names (D0-D5, M0-M7) than the pins talked about in 'some' of the few reference materials (TKD0-TKD5, TK0-TK7). As I have noticed in reading discussions about this platform makes communication confusing.
Further puzzles:
Lets take the truely useless pin designated as TKD3. It appears not to be capable of input or output. It is actually mapped to an analog pin. The documentation provides a table of an Arduino Uno (relevance?), the robot control board, the 32U4 and the register the pin is associated with:
[b]Uno ARCB/? 32U4 Reg[/b]
A4 TKD3/D22* PF1 ADC1
*This is labeled D3 on the silk screen
The Digital pin is mapped to an analog pin, nominally this shouldn't be a problem. I've tried setting the pin to Input mode using A4, PF1, as well as D3, D22, and TKD3 (all of these values are defined and = 22) with nary a response. What I am seeking is:
"Is anyone else out there working with the Arduino Robot Kit and have you seen any of these behaviors? Is my particular device simply broken or is there something I have missed in the documentation?"
I get it now, The Arduino Robot is a discontinued product. We will drop it from our evaluation list. Too bad, though, for all its quirks it had the potential for a nice classroom platform.
After getting down in the weeds of using Analog pins as DIO I suspect there is more to PaulS message than I originally gave credit. On the Robot the analog pin for TKD3 is probably being used for some undocumented purpose and is unavailable otherwise. The other pins: TKD0-TKD2 seem to be available for input.
UPDATE:
I FOUND IT. A small defect in a solder trace. I tested the continuity and reconnected TKD3 with a light wave of my [heated] wand. I also found the output capability working as well. I had been testing with a small LED but evidently the TKD0-TKD3 pins don't put out enough current to drive an LED. My scope showed that the pins are indeed switching when unloaded. All is well as far as this machine is concerned. I have a hall probe encoders working on the wheels, IR and sonic[ping] sensor for ranging, an IR detector for reading from a remote control. The cool thing is that I can make a box of sensors and outputs that simply plug onto the board. Cool toy.
People had trouble connecting nRF24 radios to Leonardos because the SPI pins were different. But you can do things similar to the Leonardo's functionality with HoodLoader. Did anyone use the Leonardo for USB host applications?