Pages: [1]   Go Down
Author Topic: how/where to connect a light sensor 3 pin  (Read 2125 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi all, so this will be my first arduino task. connect a 3 pin light sensor like this one:



as you can see it has a white, red and black cables, red wire = power, black wire = ground, white wire = sensor output, since its a analog(?) sensor i wonder if this white cable shall be connected to any of the analog ins of the arduino, and if so.

red->5v
black->ground
white->????

i will greatly appreciate the code to activate its input over usb and an easy way to read that either in processing or arduino003

yeap, i checked on the examples but they where either to advanced in code or to limited to the use of leds, so i couldn find one from where to clear my doubts.

I will document here all my findings so please help me find the right track with this kind of sensor.

merci bien,
/a
Logged

Malmo, Sweden
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the sensor will probably work just like an ordinary potientiometer and that means that u will connect the power to the power connection on arduino and the ground to the ground on the arduino. the white cable u will connect to a analog pin.

then u use this code


int ledPin = 13;    
int lightPin = 0;      
int val = 0;  
int value1 = 575;        

void setup() {
 pinMode(ledPin, OUTPUT);
 beginSerial(9600);        
}

void loop() {

 val = analogRead(lightPin);

 
    printInteger(val);
    printByte(10);
    printByte(13);


 
if(val<value1){
     

       digitalWrite(ledPin, HIGH);
 }
 
else (  digitalWrite(ledPin, LOW));
 
         delay(200);
}




that code will get the value from the lightsensor and send it over serial to the computer (I guess it works the same with usb but since I have only worked with the serial version of arduino Im not sure) and if the value is under the value u state in the integer value1 (default to 575 this may need tweaking to match your sensor) the led at pin 13 will light up

then u can also read the value 0-1024 in a program like terminal which u can find here at the site to.

I hope this will help u.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hola zervez, thanks for your reply it did clear some of my novice doubts.

the little patch you sent is not making led 13 blinki, im sure the board gets flashed correctly so is not a case of not uploading the program correctly, i even chage int value1 to something higher or lower but it seems that the sensor (that i'm sure is working) is not passing any signal to the board.

i do a cat /dev/tty.usbserial-1B1 but nothing comes in there..(same port i'm using to upload)

any ideas? phps this sensor shall be connected in a different way? this are its specs:

Output resistancemore than 1 MOhm (0 Lux) to 10 KOhm (10,000 Lux) in parallel with 4.7 KOhm

Power supply1.0 to 10 V DC, 0.2 mA at 5 V

Cable1.0 m (39 inch), shielded, red wire = power, black wire = ground, white wire = sensor output, maximum extension 30 m (98 ft)

tx,
/a
Logged

Malmo, Sweden
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oki maybe if u look at this page it will help u some

http://webzone.k3.mah.se/projects/arduino-workshop/projects/arduino_meets_processing/instructions/ldr.html

good luck
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

tx a lot for your help zervez, i was hoping that the light sensor could work withouth the need of a breadboard and extra resistors, being the light sensor one resistor in itself...i have also tried using a potenciometer and see nothing.

my question now is, if its possible to check via console or terminal (os x) if theres any input coming in via the usb port? i can flash the board correctly but dont know how to debug it. any help on this appreciated also.

merci
/a
Logged

Forum Administrator
Offline Offline
God Member
*****
Karma: 47
Posts: 629
I find plain exciting
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

if the serial monitor inside arduino doesn't work for you then you can use goSerial http://www.furrysoft.de/

it's a terminal emulation program for the mac that's simple and quick.

massimo
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

massimo you where right, is the serial monitor inside arduino that doesn't work for me.

with the goSerial tool i have the report of the sensor

smiley

now, i guess there might be something to try to enable the serial monitor inside arduino?

anyway for now this will make my weekend busy!

tx
/a
Logged

Augsburg/Munich, Germany
Offline Offline
Jr. Member
**
Karma: 0
Posts: 68
&quot;Stay hungry. Stay foolish.&quot;
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks, massimo.
zterm just isn't that nice and simple

Oli
Logged

Pages: [1]   Go Up
Jump to: