10 years, 3 months ago.

Asking for using ADJD-S371_ColourSens library

Hello, I’m college student. I’m first touch mbed now. I ask for coding of ADJD-S371_ColourSens library. Now I try to use these library, but I cannot use well. If you don’t mind, please tell me your advice.

My estimate Goal is making product used by for visually handicapped parson. So my products will inform them their closing color by mechanical voice

I ask for coding detail of ADJD-S371_ColourSens library. I cannot complete your library at “compile”.

Using devices: LPC1114FN28/102 and LPC1768 . Following comments depend on LPC1114FN28/102. How do I repair coding details?

About ADJDColourSensor.cpp (Renamed to main.cpp)

The Upper part changed nether. Did it make a mistake? ADJDColourSensor::ADJDColourSensor(PinName dp5,- PinName dp27, PinName dp28): _sensor(dp5, dp27), _LED(dp28) (List of No. 31 to No. 33) (dp5:I2C sda, dp27:I2C scl ,dp28:DIO)

About ADJDColourSensor.h

ADJDColourSensor(PinName dp5,PinName dp27, PinName dp28); (List of No.44)

I need your advice. I look forward to your return.

Chiaki Kubo, Toyama Tech college,Toyama city, Toyama prif. ,Japan

It would be helpful if you advise what error you are getting.

Dave.

posted by David Fletcher 18 Jan 2014

2 Answers

10 years, 3 months ago.

Do not change the library use main.cpp with this code:

#include "mbed.h"
#include "ADJDColourSensor.h"
DigitalOut myled(LED1);

ADJDColourSensor colour(p28, p27, LED2);

int main() {
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

This will compile, then you just need to write the rest of your program.

Dave.

Accepted Answer
chiaki kubo
poster
10 years, 3 months ago.

Dear David Fletcher.

Thank you for your advice and quick response.

I could make compile by your assistance.

So I’m tiring to build coding of display of register of RGB color sensitive data through I2C LCD.

Thank you for your kindness.

C.kubo

You may use this code to read the RGB regs

#include "mbed.h"
#include "ADJDColourSensor.h"
DigitalOut myled(LED1);
Serial pc(USBTX, USBRX);

ADJDColourSensor colour(p28, p27, LED2);

int main() {
    
    pc.baud(115200);
    
    colour.readColors();
    
    printf("Red: %i\r\n",colour.red());
    printf("Blue: %i\r\n",colour.blue());
    printf("Green: %i\r\n",colour.green());
    
    while(1) {
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}

This will compile but you will need something like terraTerm to see the data.

Dave.

posted by David Fletcher 20 Jan 2014

Dear Mr. David Fletcher

Thank you for your sending sample code last week. Still now, I think this coding of I2C color sensor. I would like to ask for your assistance.

My goal is logging data of RGB & C at color sensor and using terra Term to see the data. Now I could not precede this project.

I thought your sending c ++ language code. Following is your sending code on 20 Jan. In this code of line 12 “colour.readColors();” is not declaration before. And code of line 14 through 16 : colour.red() colour.blue() colour.green() is not relation. Maybe I must think these codes deeply.

#include "mbed.h"

#nclude "ADJDColourSensor.h" DigitalOut myled(LED1); Serial pc(USBTX, USBRX); ADJDColourSensor colour(p28, p27, LED2);

int main() {

pc.baud(115200);

colour.readColors();

printf("Red: %i\r\n",colour.red());

printf("Blue: %i\r\n",colour.blue());

printf("Green: %i\r\n",colour.green());

while(1) {

} }

So if you don’t mind, please tell me your advice. I thought point of your code, but I’m looking for solution now.

Following is 1st point of my thought. Probably this parameter is key point, but I could not use it. About “ADJDColourSensor.h” Code of Line 62 float red, green, blue;

Following is 2nd point of my thought. About “ADJDColourSensor.cpp”. Code of Line 175 to 178. Probably this parameter(red, green, blue is key point I think.

Convert the private int values into the output float values

red = (float)_red;

green = (float)_green;

blue = (float)_blue;

clear = (float)_clear;

Now and then I made following code, but not to complete.

#include "mbed.h"

#include "ADJDColourSensor.h" DigitalOut myled(LED1); Serial pc(dp16, dp15);

ADJDColourSensor colour(p28, p27, LED1);

int main(){

pc.baud(115200);

ADJDColourSensor.read();

printf("Red: %i\r\n",red); printf("Blue: %i\r\n",blue); printf("Green: %i\r\n",green);

while(1) { } }

Following is Error’s list:

Error: Expected an identifier "ADJDColourSensor.read() ;"

Error:Identifier “red” is undefined”printf(“Red: %i\r\n”,red);

Error: Identifier “red” is undefined”printf(“Red: %i\r\n”,blue);

Error: Identifier “red” is undefined”printf(“Red: %i\r\n”,green);

I am looking for solution this code. If you don’t mind, please tell me your thought.

C.Kubo

posted by chiaki kubo 30 Jan 2014