Arduino <-> ColorPal interface questions

What we have is a Arduino Mega and a ColorPal sensor.

Special for the ColorPal is the bi-directional I/O. Thus, a single I/O pin. From what I understand is that the Arduino works with tr and tx. Two pins.

So, this needs a special solution.

I tried to switch tr and tx from one pin to the other:

#include <SoftwareSerial.h>

#define rxPin 2
#define txPin 3

char colorvalue_upper;
char colorvalue_lower;

// set up a new serial port
SoftwareSerial mySerialOut = SoftwareSerial(rxPin, txPin);
SoftwareSerial mySerialIn = SoftwareSerial(txPin, rxPin);

void setup() {
}

void loop() {
// define pin modes for tx, rx:
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
// set the data rate for the SoftwareSerial port
mySerialOut.begin(7200);
mySerialOut.print("= R !");
delay(1000);

// define pin modes for tx, rx:
pinMode(rxPin, OUTPUT);
pinMode(txPin, INPUT);
mySerialOut.print("= G s !");
// set the data rate for the SoftwareSerial port
mySerialIn.begin(7200);
colorvalue_upper = mySerialIn.read();
delay(1000);
Serial.print(“value = “);
Serial.print(colorvalue_upper);
Serial.print(”\n”);
}

Only the led commands are working fine. But, no sensor values are read.

A hardware solution is given in the parallax forum: forums.parallax.com/forums/default.aspx?f=36&m=435928

Did not try the hardware solution yet. But, is there a software solution?

However, in case it will work I have another question.

The sensor value output is in three hexadecimal digits. But a serial.read is a char. Any idea how to solve this one?

Quovadis, did you have any luck with this? I am interested to know. :)

No.

What did we try up till now: We understood we where on the wrong path. Single I/O with the wrong library (the normal serial i/o tx & tr) will not work of course. So, we tried the library for single pin I/O however no success. Are we not able to understand the single pin I/O examples?

Now we are using the trick with diode (schematics found somewhere in this forum). So, we have again a tr/tx 2 wire serial connection. Back to the two wire library. Now we are able to set de leds again!! However, still not able to get measured light values. Next week or the week after that we are going to put more effort into the readout.

Sorry to hear of the difficulty in setting it up. I bought the colorpal recently without doing any research and it seems there's more help and examples available for the " ADJD-S371". However, I found this......http://itp.nyu.edu/physcomp/sensors/Reports/DIYColorSensor........An example of how to make your own colour sensor with an RGB and an LDR. Mightn't be as accurate as a dedicated sensor but may be enough for certain projects. Let me know how it goes with the colorpal and good luck!!! :)

This also may be of interest to anyone building their own.......http://www.robotroom.com/ReversedLED.html :)

We will stick to the colorpals for now (we bought already three of them). However, the DIY code is interesting.

Thanx for the two links.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1276173955/6#6

This is from another thread I was using. This guy seems to be having some luck! :)

Thanx for this link. Next week I will try this program!!

Will reply with our findings.

Well I tried this link and the program that's there and at first it didn't work. Then I switched the colorPAL from 5v to 3.3v and it worked. Don't know why but tell me if you have similar issues! Good luck :)