Community
cancel
Showing results for 
Search instead for 
Did you mean: 
AJurk2
New Contributor I
1,380 Views

Photoresistor, Galileo Gen 1, Python pyGalileo library - little confustion

I have Galielo Gen1 and Debian Linux on SD Card working good. I use pyGalileo library to manage pins from Python scripts.

I can do LED Blinking as in youtube film: https://www.youtube.com/watch?v=_xaCrHob--U&list=UUyjJWfgBdAb50_JOqQ3Utdg LED blinking - YouTube.

Everything is also on Superteacher's Blog: http://www.superbelfrzy.edu.pl/linux-i-wioo/galileo-dalsze-postepy-w-pracy/ http://www.superbelfrzy.edu.pl/linux-i-wioo/galileo-dalsze-postepy-w-pracy/ (in polish language only, but code is in python ;-)

OK - that works well, so I try today to connect photoresistor to Analog A0 pin and try top read. The film is showing voltage : https://www.youtube.com/watch?v=5ws2DdMLtOk&feature=youtu.be VID 20150401 115913 - YouTube

The python code is:

while True:

foto_value = analogRead("A0")

print "Value is: "+ str(foto_value)

delay(5000)

The output is:

Value is: 2

Value is: 3

Value is: 2

Value is: 3

Value is: 3

Value is: 3

Value is: 3

Value is: 3

It looks like something is not working like should be. But even investigating pyGalileo source code does not gave me ani hint, why... Maybe someone will help?

Tags (1)
2 Replies
RBrad2
Valued Contributor I
105 Views

Hi Abix

It is a bit difficult to figure out you problem without the rest of the code and a sketch or picture of your setup.

Are you using a voltage divider circuit with you LDR? From the video you posted it looks like you are just reading across the LDR. You need to connect the LDR from +5V to a resistor (about 10K works well) and then ground the other side of the resistor. You then take your readings from the junction of the LDR and resistor. see http://www.instructables.com/id/How-to-Use-a-Light-Dependent-Resistor-LDR/ How to Use a Light Dependent Resistor (LDR) for an example.

Did you try the example in PyGalileo?

rgb

AJurk2
New Contributor I
105 Views

Works like a charm ;-)

root@coderdojo-galileo:~/python_scripts# python fotorezystor_test.py

test pin on

test pin off

Value is: 862

Value is: 862

Value is: 861

Value is: 862

Value is: 864

Value is: 862

Value is: 828

Value is: 1990

Value is: 1978

Value is: 1972

Value is: 1968

Value is: 1966

Value is: 825

Value is: 837

Value is: 609

Value is: 637

Value is: 858

Value is: 829

Value is: 207

Value is: 181

Value is: 862

I have made 2 mistakes I think:

1) I've put "A0" in python code - should be "A5" - I look from secod side ;-)

2) Ground wire was connected to the opposite side of Galileo pins - I found strange behavior with LED blinks - if I connect pin4 and ground in the same series of pin, the light is bright, but when GND is from series of pins where 3,5 V and 5V is, the led blinks very little....

Nevertheless this problem is SOLVED ;-) rgba - thanks for any hints.

Reply