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.
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;
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.
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 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.