Show Posts
Pages: 1 2 [3] 4 5 6
31  Using Arduino / Sensors / HDJD-S822 Color Sensor Code? on: December 22, 2012, 09:28:23 am
Hello everyone
i bought a HDJD-S822 Color Sensor from sparkfun. I search the hole internet but i found just one code for it
Code:
/*
An Arduino code example for interfacing with the
HDJD-S822-QR999 Color Sensor.  Put an object in front of the
sensor and look at the serial monitor to see the values the sensor
is reading.  Scaling factors and gains may have to be adjusted
for your application.

by: Jordan McConnell
 SparkFun Electronics
 created on: 1/24/12
 license: OSHW 1.0, http://freedomdefined.org/OSHW
 
Connect the gain pins of the sensor to digital pins 7 - 12 (or ground).
Connect the led pin to digital 13.
Connect Vr to analog 0, Vg to analog 1, and Vb to analog 2.
*/

// Define pins
const int ledpin = 13;
const int GSR1 = 12;
const int GSR0 = 11;
const int GSG1 = 10;
const int GSG0 = 9;
const int GSB1 = 8;
const int GSB0 = 7;

int redpin = A0;
int greenpin = A1;
int bluepin = A2;

// Sensor read values
int red = 0;
int green = 0;
int blue = 0;

void setup()
{
  Serial.begin(9600);

  pinMode(ledpin, OUTPUT);
  pinMode(GSR1, OUTPUT);
  pinMode(GSR0, OUTPUT);
  pinMode(GSG1, OUTPUT);
  pinMode(GSG0, OUTPUT);
  pinMode(GSB1, OUTPUT);
  pinMode(GSB0, OUTPUT);

  // Turn on the LED
  digitalWrite(ledpin, HIGH);
 
  // Set the gain of each sensor
  digitalWrite(GSR1, LOW);
  digitalWrite(GSR0, LOW);
  digitalWrite(GSG1, LOW);
  digitalWrite(GSG0, LOW);
  digitalWrite(GSB1, LOW);
  digitalWrite(GSB0, LOW);
}

void loop()
{
 
  // Read sensors
  // On page 7 of the datasheet, there is a graph of the
  // spectral responsivity of the chip.  Scaling factors were
  // selected based on this graph so that the gain of each
  // color is closer to being equal
  red = analogRead(redpin) * 10;
  green = analogRead(greenpin) * 14;
  blue = analogRead(bluepin) * 17;

  // Print values to the serial monitor
  Serial.print("Red: ");
  Serial.print(red, DEC);
  Serial.print("\t\tGreen: ");
  Serial.print(green, DEC);
  Serial.print("\tBlue: ");
  Serial.println(blue, DEC);

  delay(200);
}

i connected the pins as it says then i get this result now i don't know what to do with these?
Code:
Red: 20 Green: 350 Blue: 153
Red: 20 Green: 364 Blue: 153
Red: 10 Green: 280 Blue: 119
Red: 0 Green: 336 Blue: 221
Red: 0 Green: 336 Blue: 221
Red: 160 Green: 336 Blue: 204
Red: 160 Green: 336 Blue: 204
Red: 150 Green: 294 Blue: 170
Red: 170 Green: 336 Blue: 204
Red: 160 Green: 308 Blue: 187
Red: 180 Green: 378 Blue: 255
Red: 170 Green: 336 Blue: 204
Red: 170 Green: 336 Blue: 221
Red: 170 Green: 336 Blue: 204
Red: 180 Green: 364 Blue: 238
Red: 170 Green: 336 Blue: 204
Red: 180 Green: 378 Blue: 238
Red: 170 Green: 336 Blue: 204
Red: 180 Green: 37
i want to make something like when it detect red write in serial monitor red, same for other colors?
Please help me and i will be thanks full
thanks for replaying
32  Using Arduino / Programming Questions / Re: Webduino authentication and webserver servo control ? on: December 20, 2012, 08:12:08 am
Code:
//Code by zhiran.taha@yahoo.com


#include <String.h>
#include <SPI.h>
#include <Ethernet.h>
/////////////////////////////////////////////////////////
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 178}; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // ip in lan
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(80); //server port
String readString; //
boolean login=false;

/////////////////////////////////
void setup(){
Ethernet.begin(mac, ip);
Serial.begin(9600);
    Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
  login = false;
}
void loop(){
EthernetClient client = server.available();
if (client) {
  boolean currentLineIsBlank = true;
  while (client.connected()) {
    if (client.available()) {
      char c = client.read();
        readString.concat(c);
      if (c == '\n' && currentLineIsBlank) {
        // Serial.print(readString);
       
        if(readString.indexOf("User=user&Pass=user") > 0) {
login=true;
        }
           
        ////////////////////////////////////////////////////////////////////////////
       
        if(login==true){
     
        if(readString.indexOf("Logout") > 0) {

          login=false;
     
          }     
        }
        /////////////////////////////////////////////////////
if (login == false) {
        client.println("HTTP/1.1 200 OK");
        client.println("Content-Type: text/html");
        client.println();
        client.print("<html>");
        client.println("<meta http-equiv=\"refresh\" content=\"60\">");
       client.println(" <head><title>website title</title><center></head><body> ");
       client.println("<h1>Welcome to Website</h1><hr />");
        if (login == false) {
        client.println("<h1>Please login to control!</h1>");
        client.print("<form action='192.168.1.178/'>");
        client.print("");
        client.print("Username: <input name='User' value=''>");
        client.print("Password: <input type='Password' name='Pass' value=''>");
        client.print("<input type='submit' value=' Login '>");
        client.print("<hr /></form><hr />");
               
        }
}
        ////////////////////////////////////////////////////////////////////////////
        if (login==true) {
      client.print("you get access");
        client.print("<h2><a href='/?Logout'>Logout</a>");
        client.println("<hr />");
        client.print("<span><strong>Project by Zhiran</strong?</span>");
       
        } //chiude if login=true
        client.println("</center></body></html>");
 
        //clearing string for next read
        readString="";
        //stopping client
        client.stop();
       
 
        }
    }
  }
}

}

33  Using Arduino / Project Guidance / Re: GPS navigation and arduino? on: December 09, 2012, 02:23:20 pm
or is there any alternative way to do something like that?
34  Using Arduino / Project Guidance / GPS navigation and arduino? on: December 08, 2012, 01:59:26 pm
Is it possible to make a gps navigation by arduino, where ever you are show you your home way?
35  Using Arduino / Project Guidance / Re: question about arduino+compass sensor+playing audio? on: November 20, 2012, 11:30:50 am
no answer?
36  Using Arduino / General Electronics / Re: get heat from battery (question)? on: November 20, 2012, 11:29:21 am
thanks all for the replays smiley
37  Using Arduino / General Electronics / Re: get heat from battery (question)? on: November 16, 2012, 11:06:18 am
the time as fast as it can
38  Using Arduino / General Electronics / Re: get heat from battery (question)? on: November 16, 2012, 09:44:11 am
the amount of water is less than 2 L and change  the temperature up to  25c from 10c
39  Using Arduino / General Electronics / Re: get heat from battery (question)? on: November 16, 2012, 09:37:06 am
can i get a enough heat by 9v  battery and normal heating element??

Enough heat for what? You'll get better answers if you tell people what you're trying to do.



for water!
40  Using Arduino / General Electronics / Re: get heat from battery (question)? on: November 16, 2012, 09:27:20 am
can i get a enough heat by 9v  battery and normal heating element??
41  Using Arduino / General Electronics / Re: get heat from battery (question)? on: November 16, 2012, 09:23:38 am
i couldn't what you all said
please explain it clearly!
42  Using Arduino / General Electronics / get heat from battery (question)? on: November 16, 2012, 08:15:54 am
hi
i want to convert 9v battery or 12 volt battery into heat, i mean to get a heat from the battery to warm something up, it not important if the heat is not too much??
is it possible?
43  Using Arduino / Project Guidance / question about arduino+compass sensor+playing audio? on: November 16, 2012, 08:12:31 am
hi
i want to use a compass sensor instead of writing the degrees in serial monitor i want to get the result by sound, is there anything that can do that job connected with arduino and play custom sound
like we have 8 direction for each direction play a sound??
thanks for replaying
44  Using Arduino / Project Guidance / Re: A question about arduino mega? on: November 13, 2012, 11:10:35 am
Thanks.for replay
I mean that can arduino mega run 2 diffrenet sketch at the same time
45  Using Arduino / Project Guidance / A question about arduino mega? on: November 13, 2012, 09:13:58 am
hello
i'm not at all new to arduino
but i have a question , before i made a like 3 project by arduino uno but when the arduino read the temperature and reading serial port it became to slow, it wasn't function well
my question here is mega can run multiple sketch or task at the same time like
reading color sensor+reading ultrasonic distance sensor and more??
please replay
with my best regards smiley
Pages: 1 2 [3] 4 5 6