Loading...
  Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: Problem with color sensor on: October 06, 2012, 02:14:45 pm
Not able to figure out anything  smiley-cry
2  Using Arduino / Sensors / Re: Problem with color sensor on: October 06, 2012, 01:43:11 pm
i get my readings but they are all gibberish, i have set baud rates correctly but still the readings are in negative and above 1000.
3  Using Arduino / Sensors / Problem with color sensor on: October 06, 2012, 01:22:12 pm
Hi all , i am having trouble with making this color sensor work. I dont know what i have done wrong in my code but i am not able to get it to work.

This is the code i am using:
Code:
char color[19];

void setup(){
  Serial.begin(9600);
  Serial.write("Ready");
  Serial.println();
  delay(100);
}

void loop(){
  if(Serial.available() != 0){
    for(int x=1; x<18; x++){
      color[x] = Serial.read();
      if(color[18] == 0x0A){
        Calibrate();
      }
    }
  }
}

void Calibrate(){
  int R;
  int G;
  int B;
 
  R = (((color[3]-'0')*100) + ((color[4]-'0')*10) + (color[5]-'0'));
  G = (((color[9]-'0')*100) + ((color[10]-'0')*10) + (color[11]-'0'));
  B = (((color[15]-'0')*100) + ((color[16]-'0')*10) + (color[17]-'0'));
 
  Serial.println(R);
  Serial.println(G);
  Serial.println(B);
  Serial.println();
}

And this is the datasheet of the sensor:  http://www.sunrom.com/files/1185-datasheet.pdf

I need advice and help on how to get this working fast.
Thx in advance.

Amruth

4  Using Arduino / Programming Questions / Re: Problem with arduino maths on: May 23, 2012, 12:44:24 am
Thx james for solving my problem, thats the answer i wanted, so sin() takes int radians and give degrees. Thx smiley-lol
5  Using Arduino / Programming Questions / Re: Problem with arduino maths on: May 23, 2012, 12:31:19 am
I want the degrees converted to radians and thats what sin() does but the answer is wrong, why. Need help with this.  smiley-confuse
6  Using Arduino / Programming Questions / Re: Problem with arduino maths on: May 23, 2012, 12:23:41 am
When i try using radians(140); the answerr returns as 0.
7  Using Arduino / Programming Questions / Re: Problem with arduino maths on: May 23, 2012, 12:17:35 am
I want to find sin(140) and the calculator returns 0.6, how do i do that in arduino.  smiley-confuse
8  Using Arduino / Programming Questions / Re: Problem with arduino maths on: May 23, 2012, 12:06:21 am
Ok, i will try using radians.
9  Using Arduino / Programming Questions / Re: Problem with arduino maths on: May 23, 2012, 12:02:08 am
The sin function takes degrees. In my case it 70 degrees that is the Angle Of Fire (AOF).
10  Using Arduino / Programming Questions / Problem with arduino maths on: May 22, 2012, 11:42:22 pm
Hi everyone, i am using the math.h or the first time and when the arduino does the math the answers of the arduino and the calculator have atleast a difference of 2. Thats a big difference which i dont  want.Below is the code i used for doing the math.
Code:
#include <math.h>

double u;
double t;
double a;
double f;
int m = 4;
int v = 0;
double g = 9.8;
int d = 1;
int AOF = 70;

void setup(){
  Serial.begin(9600);
  u = sqrt((g*d)/sin(2*AOF));
  Serial.print("Velocity = ");
  Serial.println(u);
  Serial.println();
  t = 2*(u*sin(AOF))/g;
  Serial.print("Time = ");
  Serial.println(t);
  Serial.println();
  a = -1*((v-u)/t);
  Serial.print("Acceleration = ");
  Serial.println(a);
  Serial.println();
  f = m*a;
  Serial.print("Force = ");
  Serial.println(f);
}

void loop(){
}

These are the answers i get form the arduino-
velocity = 3.16
time = 0.5
acceleration = 6.33
force = 25.33

These are the answers from the calc -
velocity = 3.95
time = 0.7
acceleration = 5.somthing (dont remember)
force = 23.something

I coudnt find out wat i was doing wrong, plz give me ur advices on how to get the arduino answer as close as i can to the calculators or is this the best arduino can do. Plz need help.
Pages: [1]