Show Posts
Pages: [1] 2
1  Using Arduino / Sensors / Re: Can't read Atlas Scientific colour detector on: February 04, 2013, 06:42:29 pm
did a quick test with the default code for serial communication and tested against a black surface and got a reading of (0,0,0) so sensor seems to be responding correctly... but then entering the code above I dont receive any 0's 
2  Using Arduino / Sensors / Re: Can't read Atlas Scientific colour detector on: February 04, 2013, 06:09:05 pm
hmm,

not getting a difference when putting into a completely black area (0,0,0)

I did notice tho, when I removed the sensor from the arduino I still continue to receive readings... that cant be good right?
3  Using Arduino / Sensors / Re: Can't read Atlas Scientific colour detector on: February 03, 2013, 04:48:06 pm
Thanks

this give me this...

Code:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); 

void setup() 
{
  Serial.begin(38400);
  Serial.println("Start color sensor");

  // set the data rate for the NewSoftSerial port
  mySerial.begin(38400);
  mySerial.print('C');
}

void loop()
{
  if (mySerial.available())
  {
    unsigned char c = mySerial.read(); // <------------ added unsigned char
    Serial.print("<"); 
    Serial.print(c, DEC); 
    Serial.print(">");
    if (c == ',') Serial.println(); // split the R G and B
    if (c == 13) Serial.println(); // extra newline
   

  }
      delay(1000);
}


I also added a delay just to see what I was getting from the sensor in one loop. the resulting data is somelike like:

Code:
<51>

10 seconds of running the serial monitor, i get something like:

Code:
b,Start color sensor
<49><56><44>
<177><147><148><152><156><134><49>
4  Using Arduino / Sensors / Re: Can't read Atlas Scientific colour detector on: February 03, 2013, 04:31:28 pm
I just updated your code

Code:
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); 

void setup() 
{
  Serial.begin(38400); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<< changed to 38400
  Serial.println("Start color sensor");

  // set the data rate for the NewSoftSerial port
  mySerial.begin(38400);
  mySerial.print('C');
}

void loop()
{
  if (mySerial.available())
  {
    char c = mySerial.read();
    Serial.print("<");
    Serial.print(c, DEC); 
    Serial.print(">");
    if (c == ',') Serial.println(); // split the R G and B
    if (c == 13) Serial.println(); // extra newline
  }
}

That gives me this

Code:
b,¡¡¤%¥¡%%%Start color sensor
<52><51><44>
<-77><-108><-106><-103><-102><-122><50><53><44>
<-79><-107><-106><-104><-103><-122><50><53><44>
<-78><-111><-108><-103><-104><-122><50><53><44>
<-78><-103><-106><-103><-104><-122><50><49><44>
<-79><-104><-108><-104><-100><-122><50><52><44>
<-79><-103><-106><-102><-103><-122><52><51><44>
<-77><-111><-106><-103><-102><-122><52><48><44>
<-78><-104><-106><-103><-103><-122><49><48><44>
<-79><-104><-106><-102><-103><-122><51><50><44>
<-78><-104><-106><-103><-103><-122>
5  Using Arduino / Sensors / Re: Can't read Atlas Scientific colour detector on: February 03, 2013, 04:04:55 pm
what is unusual,

I can only start the readings when I pull out the 5v and ground and reinsert into the arduino. The sensor also works without the 5v wire.
6  Using Arduino / Sensors / Re: Can't read Atlas Scientific colour detector on: February 03, 2013, 04:00:36 pm
ah yes, that makes sense then sensor runs at 38400,

changing that shows this

Code:
b,Start color sensor
495253-84494853-84494857-115495250-84494850-84494854-115495253-84494853-844948-75-115495253-84494853-84494853-115545344
-76-105-108-103-104-122544944
-108-99-106-102-102-122
7  Using Arduino / Sensors / Re: Can't read Atlas Scientific colour detector on: February 03, 2013, 03:35:35 pm
cool,

im getting a new reading roughly every second now...

Code:
ɵÁ\•Ð‚ p€aఉÁY` 1€aÿ‰ðÉÜp€aàЁ‰£ p€#ఉ‘‹¡ p€#øÐʼn£ p€#àðɑ‹! p€øÌùñ 0€apÀ̹±‹á cøÐʼn£ p€#ఙÁK°cà‚Ùpcà
8  Using Arduino / Sensors / Re: Can't read Atlas Scientific colour detector on: February 03, 2013, 03:00:58 pm
thanks for that,

I open up the serial monitor and get this...

Code:
͹ÙL

(values change when i close and re-open the monitor) for example:

Code:
Ô»Ðó

Code:
ݽùÌ
9  Using Arduino / Sensors / Re: Can't read Atlas Scientific colour detector on: February 03, 2013, 02:42:36 pm
Thanks for that,

ive just tried verify this and get the following error:

'NewSoftSerial' does not name a type.

im running 1.0.3

Cheers,

Phil
10  Using Arduino / Sensors / Re: Can't read Atlas Scientific colour detector on: February 03, 2013, 12:44:19 pm
I bought one of these sensors a week ago and struggling to get it working properly. The code they provided did not work.

Ive managed to get a reading through the serial, digital 0, 1 pins and then entering this code:

Code:
void setup() {}
void loop(){}

opening the serial reader and entering "C" to start taking a reading at 620ms. you should get something like this.

Code:
14,8,414,14,1410,10,1413,18,18

What I would like to know is how can you use soft serial and strings to be able to take a reading that arduino can then do something with.
11  Forum 2005-2010 (read only) / Troubleshooting / Re: led fade from 0 to 225 then hold at 255 on: December 05, 2010, 06:31:20 pm
intially the led would be set at 0
when pressed and held it would go from 0 to 255 and once there stay at 255
when pressed again it would go from 255 to 0

but also what I would like it to do is, say the button was pressed and it started to brighten, if the button was pressed again before the led got to 255 it would take the current value and got back down to 0.

The project Im looking to do is control a series of leds with in IR sensor, when the user comes into range of the sensor this triggers the leds to fade in, if the were to stay they would see all the leds come on. if they were to walk away the leds would fade out. A quick swipe with the hand would start to activate the leds but then they would fade out again quickly

Hope this helps

Ahh ill try use switches from now on, pretty new to all this  

Yeah further on in the book it talks about debouncing I thought it would be better to leave it out for now to make it more simple for myself  :smiley


12  Forum 2005-2010 (read only) / Troubleshooting / led fade from 0 to 225 then hold at 255 on: December 05, 2010, 06:06:54 pm
Hi,

Im trying to create a bit of code that when a button is pressed its fades in a led to full brightness and then the led stays on.

Ive got the getting started with arduino book and adapted a bit of code that will turn an led on and off with a button press to now fade in, but the loop when it gets to the 255 value just resets to 0 and fades in again.

Ive been looking at breaks and trying to include them in my code but had no luck so far.

this is the bit of code i have so far
Code:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  9;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int fade = 0;

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);    
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {    
    for (fade = 0; fade <= 255; fade++){
    analogWrite(ledPin, fade);
    delay(15);
  }
 }
  else {
    // turn LED off:
    for (fade = 255; fade > 0; fade--){
    analogWrite(ledPin, fade);
    delay(15);
   }
  }
}


Thanks in advance, Phil
13  Forum 2005-2010 (read only) / Interfacing / Re: taking two sensor readings over time on: December 27, 2010, 03:54:04 pm
Thanks nightfigther, got it working  ;D

Code below:

Code:
int analogInPin = A0; // define IR Sensor
int analogOutPin = 9; // define LED
int oldValue;
int currentValue;

void setup() {
  oldValue = 0; //Set the values to be 0 when we first start
  currentValue = 0;
  Serial.begin(9600);


}

void loop() {
oldValue = currentValue; //Every iteration the Arduino runs through, //assign oldValue to be what the previous currentValue is.
currentValue = analogRead(analogInPin);  //assign currentValue to the what //the function returns
 


//do our logic tests
if((oldValue < 50) && (currentValue >= 400)) {
digitalWrite(analogOutPin, HIGH);
delay(1000);
}
else
{
digitalWrite(analogOutPin, LOW);
}
// print the results to the serial monitor:
  Serial.print("sensor = " );                      
  Serial.println(currentValue);      
  
  // wait 10 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(1000);    

} //End Loop();
14  Forum 2005-2010 (read only) / Interfacing / Re: taking two sensor readings over time on: December 27, 2010, 02:07:44 pm
After a good lot of searching im still none the wiser

does anyone have any useful tutorials on Arrays, im finding it hard to work out how arduino knows where to get values from and how to deal with them for my problem above.

Thanks, Phil
15  Forum 2005-2010 (read only) / Interfacing / Re: taking two sensor readings over time on: December 17, 2010, 08:26:57 am
Ah that's great, just what I was looking for.
Pages: [1] 2