Hey and Hello,

I got the info. more suited to abide by actual rules instead of guessing 
like I did do earlier in my source.

...

Thank you for the links. I did get some help on Freenode too. I will look 
over the links. I have them up now.

Seth

P.S. Here is a setup maybe worth while?

from LDRone import MCP3008
import time

adc = MCP3008(bus=0, device=0, vref=3.3)

try:
    while True:
        voltage = adc.read(channel=0)                   # across resistor
        current = voltage * 10000                       # through resistor 
and LDR
        resistance = (adc.vref - voltage) / current     # of LDR
        print("voltage: \t", voltage)
        print("current: \t", current)
        print("resistance: \t", resistance)
    time.sleep(4)

except:
    print("Get gone!")
    pass


Here is LDRone.py

from Adafruit_BBIO.SPI import SPI

class MCP3008:
    def __init__(self, bus, device, vref):
        self.vref = vref
        self.spi = SPI(bus, device)

    def read(self, channel):
        data = self.spi.xfer2([1, (8 + channel) << 4, 0])
        value = ((data[1] & 3) << 8) + data[2]
        return value * self.vref / 1023

    def close(self):
        self.spi.close()



On Sunday, November 10, 2019 at 6:52:42 PM UTC-6, Dennis Bieber wrote:
>
> On Sat, 9 Nov 2019 21:19:35 -0800 (PST), in 
> gmane.comp.hardware.beagleboard.user Mala Dies 
> <[email protected] <javascript:>> wrote: 
>
> > 
> >from LDRII import MCP3008 #I found this source online and I cannot figure 
> >out what site I found it at currently. Anyway...if this is your source, 
> say 
> >so! I will give you credit. 
> > 
>         Based on Google, the MCP3008 is a multichannel ADC. The Raspberry 
> Pi 
> examples require it because the R-Pi only has binary GPIO. 
>
>         The BBB has internal ADC (though limited to 1.8V peak, so one 
> often 
> needs a voltage divider to reduce 3.3V (or 5V) data to fit into 0..1.8V) 
> (for safety, one might want to limit the peak to 1.7V, and adjust the 
> conversion equation somewhat). 
>
> https://www.linux.com/tutorials/how-get-analog-input-beaglebone-black/ 
>
> https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/adc
>  
>
> > 
> >from LDRII import MCP3008 #I found this source online and I cannot figure 
> >out what site I found it at currently. Anyway...if this is your source, 
> say 
> >so! I will give you credit. 
> > 
>         Based on Google, the MCP3008 is a multichannel ADC. The Raspberry 
> Pi 
> examples require it because the R-Pi only has binary GPIO. 
>
>         The BBB has internal ADC (though limited to 1.8V peak, so one 
> often 
> needs a voltage divider to reduce 3.3V (or 5V) data to fit into 0..1.8V) 
> (for safety, one might want to limit the peak to 1.7V, and adjust the 
> conversion equation somewhat). 
>
> https://www.linux.com/tutorials/how-get-analog-input-beaglebone-black/ 
>
> https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/adc
>  
> -- 
> Dennis L Bieber 
>
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/93033cad-67aa-4cf0-8462-e0ec978d9a28%40googlegroups.com.

Reply via email to