def setup():
	ADC0832.setup()				# Setup ADC0832
	GPIO.setmode(GPIO.BOARD)	# Numbers GPIOs by physical location
	GPIO.setup(btn, GPIO.IN, pull_up_down=GPIO.PUD_UP)	# Setup button pin as input an pull it up
	GPIO.add_event_detect(btn, GPIO.FALLING, callback=button_pressed, bouncetime=100)
	global state
	state = ['up', 'down', 'left', 'right']	
Example #2
0
def setup():
    GPIO.setmode(GPIO.BOARD)  #Number GPIOs by its physical location
    GPIO.setwarnings(False)
    for pin in pins:
        GPIO.setup(pin, GPIO.OUT)  #set all pins' mode is output
        GPIO.output(pin, GPIO.HIGH)  #set all pins are high level(3.3V)
    ADC0832.setup()
Example #3
0
def init():
    ADC0832.setup()
    if ARG_DISPLAY == 1:
        print("")
        print("Analog Temperatur")
        print("")
        print("ADC")
        print("ADC		   RPI")
        print("---------------------------------------")
        print("Pin 1		-> Pin 11 (GPIO 17)")
        print("Pin 2		-> (+++Sensor+++)")
        print("Pin 3		-> (+++ ohne +++)")
        print("Pin 4		-> Pin 9  (GND)")
        print("Pin 5 (DI)	-> Pin 13 (GPIO 27)")
        print("Pin 6 (DO)	-> Pin 13 (GPIO 27)")
        print("Pin 7 (CLK)	-> Pin 12 (GPIO 18)")
        print("Pin 8 (VCC)	-> Pin 1  (3.3V)")
        print("")
        print("Sensor (beliebiger analoger Sensor")
        print("Sensor")
        print("---------------------------------------")
        print("Pin -		-> Pin 9  (GND)")
        print("Pin +		-> Pin 1  (3.3V)")
        print("Pin S		-> (+++Pin 2 ADC+++)")
        print("")
Example #4
0
def UserPickPattern():
        uArr = []
        ADC0832.setup()

        for x in range(4):
                    print"Move the red wire to your choice for the color in spot #",x+1," and press enter"
                    raw_input()
                    u = ADC0832.getResult()            #Get reading from ADC
                    if u > 248 and u < 252:
                        uArr.append(1)
                    elif u > 231 and u < 235:
                        uArr.append(2)
                    elif u > 126 and u < 130:
                        uArr.append(3)
                    elif u > 242 and u < 246:
                        uArr.append(4)
                    elif u > 211 and u < 215:
                        uArr.append(5)
                    elif u > 120 and u < 124:
                        uArr.append(6)
                    else:
                        uArr.append(0)
                    
        #print colored('0 ',colArr[uArr[0]]),colored('0 ',colArr[uArr[1]]),colored('0 ',colArr[uArr[2]]),colored('0 ',colArr[uArr[3]])
        return uArr            
Example #5
0
def setup():
    ADC0832.setup()  # Setup ADC0832
    GPIO.setmode(GPIO.BOARD)  # Numbers GPIOs by physical location
    GPIO.setup(
        btn, GPIO.IN,
        pull_up_down=GPIO.PUD_UP)  # Setup button pin as input an pull it up
    global state
    state = ['--', 'UP', 'DN', 'LF', 'RH', 'PR']
Example #6
0
def setup():
    ADC0832.setup()  # Setup ADC0832
    GPIO.setmode(GPIO.BOARD)  # Numbers GPIOs by physical location
    GPIO.setup(
        btn, GPIO.IN,
        pull_up_down=GPIO.PUD_UP)  # Setup button pin as input an pull it up
    global state
    state = ['up', 'down', 'left', 'right']
Example #7
0
def subloop():
        while True:
                screen = i2c_lcd1602.Screen(bus=1, addr=0x27, cols=16, rows=2)
                line = "Personal Project"
                screen.enable_backlight()
                screen.clear()
                ADC0832.setup()
                line = sensor(line)
                return line
Example #8
0
def readPhotoSens(chn=0):
    print "Reading light from channel: %d" % chn
    ADC0832.setup()
    photores = ADC0832.getResult(chn) - 80
    if photores < 0:
        photores = 0
    if photores > 100:
        photores = 100
    print 'Relative light = %d' % photores
    time.sleep(0.2)
Example #9
0
def readPhotoSens(chn=0):
  print "Reading light from channel: %d" % chn
  ADC0832.setup()
  photores = ADC0832.getResult(chn) - 80
  if photores < 0:
    photores = 0
  if photores > 100:
    photores = 100
  print 'Relative light = %d' % photores
  time.sleep(0.2)
def setup():
    ADC0832.setup()  # Setup ADC0832
    GPIO.setmode(GPIO.BOARD)  # Numbers GPIOs by physical location
    GPIO.setup(
        btn, GPIO.IN,
        pull_up_down=GPIO.PUD_UP)  # Setup button pin as input an pull it up
    GPIO.add_event_detect(btn,
                          GPIO.FALLING,
                          callback=button_pressed,
                          bouncetime=100)
    global state
    state = ['up', 'down', 'left', 'right']
Example #11
0
def get_light():
    try:
        ADC0832.setup()
        output_fromGPIO(pin, True)
        light = ADC0832.getResult(1) - 80
        print(light)
        if light < 0:
            light = 0
        return light
    except:
        ADC0832.destroy()
    finally:
        output_fromGPIO(pin, False)
Example #12
0
def get_moisture():
    try:
        ADC0832.setup()
        output_fromGPIO(pin, True)
        while True:
            moisture = ADC0832.getResult(0)
            if moisture != -1:
                return moisture
            sleep(1)
    except:
        ADC0832.destroy()
    finally:
        output_fromGPIO(pin, False)
Example #13
0
def setup():
    global LCDScreen
    global MAXRADIOCHANNEL
    global RadioDict

    GPIO.setmode(GPIO.BOARD)  # Numbers GPIOs by physical location
    #Rotary
    GPIO.setup(RoAPin, GPIO.IN)  # input mode
    GPIO.setup(RoBPin, GPIO.IN)
    GPIO.setup(RBtnPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.add_event_detect(RBtnPin, GPIO.FALLING, callback=btnResetChannel)

    #Potentiometer
    ADC0832.setup()
    Current_Volume_Value = Last_Volume_Value = ADC0832.getResult()

    #LCD Screen
    LCDScreen = Screen(bus=1, addr=0x3f, cols=16, rows=2)
    LCDScreen.enable_backlight()
    LCDScreen.clear()
    LCDScreen.display_data("Piper Radio", "")

    #BlueButton
    GPIO.setup(TweetBtnPin, GPIO.IN, pull_up_down=GPIO.PUD_UP
               )  # Set BtnPin's mode is input, and pull up to high level(3.3V)

    #credential setup
    if os.path.isfile("setenv.py"):
        print "running local"
        import setenv
    else:
        print "I must be in CF"

#initialize database
    initDB()
    MAXRADIOCHANNEL = getTotalStation()
    RadioDict = getListOfStation()

    #initialize polly
    initPolly()
    playWelcomeMsg()
    #delay 5 secodns before start
    sleep(5)

    #intialize radio
    initRadio(RadioDict["radioStationID:0"][1])

    #intialize ECS
    initECS()
Example #14
0
def readLuminosity():
    try:
        print("== IN READ LUMINOSITY IN THE BOX == ")
        luminosity = -100
        ADC0832.setup()
        GPIO.setup(16, GPIO.OUT)
        luminosity = ADC0832.getResult(0)
        print '## luminosity = %d' % luminosity
        GPIO.output(16, GPIO.HIGH)
        return luminosity

    except KeyboardInterrupt:  # When 'Ctrl+C' is pressed, the child program destroy() will be  executed.
        GPIO.output(pin, GPIO.LOW)
        GPIO.cleanup()  # Release resource
        return -100
Example #15
0
def setup():
    GPIO.setmode(GPIO.BOARD)  #Number GPIOs by its physical location
    GPIO.setwarnings(False)
    for pin in pins:  # Setup 7 Seg pins
        GPIO.setup(pin, GPIO.OUT)  #set all pins' mode is output
        GPIO.output(pin, GPIO.HIGH)  #set all pins are high level(3.3V)

    ADC0832.setup()  # setup ADC

    # IR Sensor setup
    GPIO.setup(IR1Pin, GPIO.IN)
    GPIO.setup(IR2Pin, GPIO.IN)

    # Buzzer setup
    GPIO.setup(BZRPin, GPIO.OUT)  # Set pin mode as output
    GPIO.output(BZRPin, GPIO.LOW)
def setup():
	GPIO.setmode(GPIO.BOARD)
	# Buzzer setup:
	GPIO.setup(Buzzer, GPIO.OUT)
	GPIO.output(Buzzer, 1)
	# RGB setup:
	GPIO.setup(LedRed, GPIO.OUT)
	GPIO.setup(LedGreen, GPIO.OUT)
	GPIO.setup(LedBlue, GPIO.OUT)
	GPIO.output(LedRed, 1)
	GPIO.output(LedGreen, 1)
	GPIO.output(LedBlue, 1)
	# DS18B20 setup:
	ds18b20Init()
	# Joystick setup:
	GPIO.setup(btn, GPIO.IN)
	GPIO.add_event_detect(btn, GPIO.FALLING, callback=joystickbtn, bouncetime=200)
	# ADC0832 setup:
	ADC0832.setup()
Example #17
0
def setup():
	GPIO.setmode(GPIO.BOARD)
	# Buzzer setup:
	GPIO.setup(Buzzer, GPIO.OUT)
	GPIO.output(Buzzer, 1)
	# RGB setup:
	GPIO.setup(LedRed, GPIO.OUT)
	GPIO.setup(LedGreen, GPIO.OUT)
	GPIO.setup(LedBlue, GPIO.OUT)
	GPIO.output(LedRed, 1)
	GPIO.output(LedGreen, 1)
	GPIO.output(LedBlue, 1)
	# DS18B20 setup:
	ds18b20Init()
	# Joystick setup:
	GPIO.setup(btn, GPIO.IN)
	GPIO.add_event_detect(btn, GPIO.FALLING, callback=joystickbtn, bouncetime=200)
	# ADC0832 setup:
	ADC0832.setup()
def setup():
	ADC.setup()
	GPIO.setup(Beep, GPIO.OUT)
Example #19
0
def init():
    ADC0832.setup()
    GPIO.setup(LedPin, GPIO.OUT)  # Set LedPin's mode is output
    GPIO.output(LedPin, GPIO.HIGH)  # Set LedPin high(+3.3V) to off led
Example #20
0
def init():
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(MIC_DO_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    ADC0832.setup()
def adcInit():
	ADC0832.setup()
def ADC0832Init():
	ADC0832.setup()
def init():
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)
    GPIO.cleanup()
    ADC0832.setup()
Example #24
0
def init():
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(Flame_DO_Pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
    GPIO.setup(LedPin, GPIO.OUT)
    ADC0832.setup()
Example #25
0
def Soil_init():
    ADC0832.setup()
Example #26
0
#
# Author : Matt Hawkins
# Date   : 17/04/2014
#
# https://www.raspberrypi-spy.co.uk/
#
#--------------------------------------

# modified By DKing
# Analog Joystick on raspberry pi using ADC0832

import ADC0832
import time
import socket

ADC0832.setup(cs=25, clk=11, dio=8)

SERVERIP = '10.0.0.43'
n = 0

# Define sensor channels
# (channels 3 to 7 unused)
vrx_channel = 0
vry_channel = 1

# Define delay between readings (s)
delay = 0.5

while True:
    # Read the joystick position data
    vrx_pos = ADC0832.getResult(vrx_channel)
def init():
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(FlamePin_S, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    GPIO.add_event_detect(FlamePin_S, GPIO.FALLING, callback=myISR)
    ADC0832.setup()
Example #28
0
def setup():
	global p
	ADC.setup()
	GPIO.setup(LED, GPIO.OUT)
	p = GPIO.PWM(LED, 2000)
	p.start(100)
Example #29
0
            cl.append(self)
            print len(cl)
            
    def on_message(self, message):
        for c in cl:
            # c.write_message(u"" + message)
            if c != self:
                c.write_message(u"" + message)
        
    def on_close(self):
        if self in cl:
            cl.remove(self)

app = tornado.web.Application([
    # (r'/', IndexHandler),
    (r'/ws', SocketHandler),
    (r'/voice', EchoSocketHandler),
    # (r'/api', ApiHandler),
    # (r'/(favicon.ico)', web.StaticFileHandler, {'path': '../'}),
    # (r'/(rest_api_example.png)', web.StaticFileHandler, {'path': './'}),
], autoreload=True)

if __name__ == '__main__':
    ADC.setup()
    server = tornado.httpserver.HTTPServer(app, ssl_options = {
        "certfile": "/etc/nginx/ssl/nginx.crt",
        "keyfile": "/etc/nginx/ssl/nginx.key",
    })
    server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()
Example #30
0
import ADC0832
import os
import datetime
import time
import smbus
import ds18b20
import i2c_lcd1602

screen = i2c_lcd1602.Screen(bus=1, addr=0x27, cols=16, rows=2)

line = "Personal Project"
screen.enable_backlight()
screen.clear()


ADC0832.setup()
#path_w = 'brightness.txt'


#for i in range(10):
# 72 で 1 時間、72x6 時間で 432 288 4 時間、864 で 12 時間

def sensor(line):
#    screen.cursorTo(0, 0)
#    screen.println(line)

# 温度検知
    t = ds18b20.dsb20Read()
    t = round(t, 1)
    m = '%f' %t
    m = m[:5]
Example #31
0
def init():
	GPIO.setmode(GPIO.BOARD)	
	GPIO.setup(Touch_DO_PIN, GPIO.IN, pull_up_down = PUD_DOWN)
	ADC0832.setup()
screen = i2c_lcd1602.Screen(bus=1, addr=0x27, cols=16, rows=2)

def destory():
	GPIO.cleanup()

def loop():
	while True:
		screen.cursorTo(0, 0)
		screen.println(line)
		t = ADC0832.getResult()
		vol = 5.0/255 * t
		vol = round(vol, 2)
		vol = '%f' %vol
		vol = vol[:4]
		screen.cursorTo(1, 0)
		screen.println(' Voltage: ' + vol + 'V ')
		screen.clear()
		time.sleep(0.2)      

if __name__ == '__main__':
	print 'www.adeept.com'
	line = " www.adeept.com "
	screen.enable_backlight()
	screen.clear()
	try:
		ADC0832.setup()
		loop()
	except KeyboardInterrupt:
		destory()
def init():
	ADC0832.setup()
def init():
	GPIO.setmode(GPIO.BOARD)	
	GPIO.setup(MIC_DO_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	ADC0832.setup()
Example #35
0
def iniyt():
    ADC0832.setup()
def setup():
	segment.TM1638_init()
	ADC0832.setup()
def init():
	GPIO.setmode(GPIO.BOARD)	
	GPIO.setup(FlamePin_S, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.add_event_detect(FlamePin_S, GPIO.FALLING, callback=myISR)
	ADC0832.setup()
def setup():
	ADC.setup()
def setup():
	GPIO.setmode(GPIO.BOARD)		# Numbers GPIOs by physical location
	GPIO.setup(BEEP, GPIO.OUT)		# Set pins' mode is output
	ADC0832.setup()					# Setup ADC0832
import Adafruit_CharLCD as LCD

# LCD setup code
lcd = LCD.Adafruit_CharLCDPlate()
GPIO.setmode(GPIO.BCM)

# GPIO ID_INTERRUPT & ADC_INTERRUPT set up as inputs,
# pulled up to avoid false detection.
# Both ports are wired to connect to GND on button press.
# So we'll be setting up falling edge detection for both
GPIO.setup(ADC_INTERRUPT, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(IP_INTERRUPT, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# ADC setup code
#This is where you change the pins for the ADC if needed
ADC.setup(cs=ADC_CS, clk=ADC_CLK, dio=ADC_DIO)

#get IP and Host name (from ipDisplay.py)
while True:
    IPaddr = subprocess.check_output(['hostname', '-I'])
    if len(IPaddr) > MIN_IP_ADDRESS_LENGTH:
        break
    else:
        time.sleep(IP_ADDRESS_WAIT)
Name = subprocess.check_output(['hostname']).strip()
displayText = IPaddr + Name

# now we'll define two threaded callback functions
# these will run in another thread when our events are detected
# They both modify the global variable ADCSelect
import ADC0832 as ADC
import subprocess
import Adafruit_CharLCD as LCD

lcd = LCD.Adafruit_CharLCDPlate()
GPIO.setmode(GPIO.BCM)

# GPIO 23 & 17 set up as inputs, pulled up to avoid false detection.
# Both ports are wired to connect to GND on button press.
# So we'll be setting up falling edge detection for both
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)

# ADC setup code
#This is where you change the pins for the ADC if needed
ADC.setup(cs=24, clk=25, dio=8)

#get IP and Host name (from ipDisplay.py)
while True:
    IPaddr = subprocess.check_output(['hostname', '-I'])
    if len(IPaddr) > 8:
        break
    else:
        time.sleep(2)
Name = subprocess.check_output(['hostname']).strip()
displayText = IPaddr + Name

# now we'll define two threaded callback functions
# these will run in another thread when our events are detected

Example #42
0
def adcInit():
    ADC0832.setup()
def setup():
    GPIO.setmode(GPIO.BOARD)  # Numbers GPIOs by physical location
    GPIO.setup(BEEP, GPIO.OUT)  # Set pins' mode is output
    ADC0832.setup()  # Setup ADC0832
Example #44
0
def setup():
	ADC0832.setup()				# Setup ADC0832
	GPIO.setmode(GPIO.BOARD)	# Numbers GPIOs by physical location
	GPIO.setup(btn, GPIO.IN, pull_up_down=GPIO.PUD_UP)	# Setup button pin as input an pull it up
	global state
	state = ['up', 'down', 'left', 'right']	
Example #45
0
def ADC0832Init():
    ADC0832.setup()
def init():
    ADC0832.setup()
    DAC.setup()
Example #47
0
def setup():
	GPIO.setmode(GPIO.BOARD)
	GPIO.setup(RAIN, GPIO.IN)
	ADC0832.setup()