Beispiel #1
0
    def __init__(self, drive):
        """ Standard Constructor """
        logging.info("Straight Line Speed constructor")
        # set up ADC
        self.i2c_helper = ABEHelpers()
        self.bus = self.i2c_helper.get_smbus()
        self.adc = ADCPi(self.bus, 0x6a, 0x6b, 12)

        # define fixed values
        self.stopped = 0
        self.full_forward = 0.5
        self.slow_forward = 0.1
        self.full_reverse = -0.5
        self.slow_reverse = -0.1

        self.left_steering = -0.25
        self.right_steering = 0.25
        self.straight = 0
        self.distance_sensor = 1

        # Voltage value we are aiming for (2 was close, 0.5 was further away)
        self.nominal_voltage = 0.5
        self.min_dist_voltage = 2.0
        self.max_dist_voltage = 0.4

        # Drivetrain is passed in
        self.drive = drive
        self.killed = False
Beispiel #2
0
    def __init__(self, drive):
        """ Standard Constructor """
        logging.info("Three Point Turn constructor")
        # set up ADC
        self.i2c_helper = ABEHelpers()
        self.bus = self.i2c_helper.get_smbus()
        self.adc = ADCPi(self.bus, 0x6a, 0x6b, 12)

        # define fixed values
        # red is typically 3.5V
        self.red_min = 3
        self.red = 3.5
        self.stopped = 0
        self.full_forward = 0.5
        self.half_forward = 0.25
        self.slow_forward = 0.1
        self.full_reverse = -0.5
        self.half_reverse = -0.25
        self.slow_reverse = -0.1

        self.straight = 0
        self.full_left = -1
        self.slow_left = -0.5
        self.rear_line_sensor = 2
        # same sensor for now
        self.front_line_sensor = 2
        self.max_rate = 2

        # Drivetrain is passed in
        self.drive = drive

        self.killed = False
Beispiel #3
0
    def __init__(self):
        """ Standard Constructor """
        logging.info("Three Point Turn constructor")
        # set up ADC
        self.i2c_helper = ABEHelpers()
        self.bus = self.i2c_helper.get_smbus()
        self.adc = ADCPi(self.bus, 0x6a, 0x6b, 12)

        self.killed = False
    def __init__(self):

        #Get the ADC fired up.
        i2c_helper = ABEHelpers()
        bus = i2c_helper.get_smbus()
        self.adc = ADCPi(bus, 0x68, 0x69, 12)

        #Open the serial port for use.
        roboclaw.Open("/dev/ttyAMA0", 38400)
        print("Serial port open!")
        self.address = 0x80

        #Networking vars. Currently set to Christian's IP and Laptop
        client_IP = "10.42.0.87"
        port = 6969
        self.server_address = (client_IP, port)

        #Set the max speed of the motors. Max/min is +32767/-32767
        self.max_speed = 20000
        self.min_speed = -20000

        #Scaling params. Experimentally obtained.
        self.adc_min = 0.600453
        self.adc_max = 4.6000

        self.mapped_max = 0  #Yes, max is zero and min is 100.
        self.mapped_min = 100  #This is due to backward wiring in TVCBey and on my part.

        #Vars needed for mapping method.
        self.adc_span = self.adc_max - self.adc_min
        self.mapped_span = self.mapped_max - self.mapped_min

        #Initializing feedbacks
        self.x_feedback = 0
        self.y_feedback = 0

        #PID Params. They're currently same for x and y
        kp = 2500
        ki = 50
        kd = 0
        sample_time = 0.001

        #Objects from the PID.py import. See documentation there.
        self.x_PID = PID.PID(kp, ki, kd)
        self.y_PID = PID.PID(kp, ki, kd)

        self.x_PID.setSampleTime(sample_time)
        self.y_PID.setSampleTime(sample_time)

        #Zero point for actuators to balance motor
        self.x_zero = 54  #Experimentally defined
        self.y_zero = 51

        self.x_output_error_range = 1500
        self.y_output_error_range = 1000
def hallSen():
    # GPIO Setup
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(7, GPIO.OUT)

    text_file = open("hallSensor_Data.txt", "w")
    initTime = time.time()

    t1 = 0
    t2 = 0
    flag = 0
    diameter = 14  # need to find the actual diameter !!!

    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    adc = ADCDifferentialPi(bus, i2cAddr1, i2cAddr2, bitRate)

    SevenSeg.initDisplay()

    while (True):
        voltage = adc.read_voltage(
            channel
        )  # voltage output from hall sensor (either a pos. or neg. value)
        curTime = time.time(
        ) - initTime  # calculates the current time from time acc. minus time started with

        if voltage < 0.0 and flag == 0:  # if voltage is neg. and we have not passed by the magnet yet
            flag = 1
            t1 = t2  # stores the previous curent time from curTime
            t2 = curTime  # stores the current time in curTime
            rps = 1 / (t2 - t1)  # revolutions per second
            mph = rps * (math.pi) * diameter * (
                3600 / 63360)  # conversion from rps to miles per second
            #mph = rps*60

            #print( str(curTime) + "," + str(voltage) + "," + str(mph) )
            #text_file.write( str(curTime) + "," + str(voltage) + "," + str(mph) + "\n" )

        elif voltage < 0.0 and flag == 1:  # else if voltage is neg. but we are currently still passing by the magnet
            #print( str(curTime) + "," + str(voltage) )
            #text_file.write( str(curTime) + "," + str(voltage) + "\n" )
            temp = 1

        else:  # else the voltage is positive (meaning the magnet is not next the the hall sensor)
            flag = 0
            #print( str(curTime) + "," + str(voltage) )
            #text_file.write( str(curTime) + "," + str(voltage) + "\n" )

        SevenSeg.displayNum(int(mph))

        #time.sleep( 0.0100 )

    text_file.close()
Beispiel #6
0
def main():
    """ Main function """
    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    adc_instance = ADCPi(bus, 0x68, 0x69, 18)

    windreader = WindReader(adc_instance)
    windreader.daemon = True
    windreader.start()

    loggers = {}
    for channel, codename in settings.channels.items():
        loggers[codename + '_raw'] = ValueLogger(windreader,
                                                 comp_val=1.05,
                                                 channel=channel + '_raw',
                                                 maximumtime=30)
        loggers[codename + '_raw'].start()
        loggers[codename] = ValueLogger(windreader,
                                        comp_val=1.005,
                                        channel=channel,
                                        maximumtime=30)
        loggers[codename].start()

    codenames = []
    for name in settings.channels.values():
        codenames.append(name)
        codenames.append(name + '_raw')

    socket = DateDataPullSocket('Fumehood Wind Speed', codenames, timeouts=2.0)
    socket.start()

    live_socket = LiveSocket('Fumehood Wind Speed', codenames)
    live_socket.start()

    db_logger = ContinuousDataSaver(
        continuous_data_table=settings.dateplot_table,
        username=credentials.user,
        password=credentials.passwd,
        measurement_codenames=codenames)
    db_logger.start()

    time.sleep(10)

    while windreader.is_alive():
        time.sleep(0.25)
        for name in codenames:
            value = loggers[name].read_value()
            socket.set_point_now(name, value)
            live_socket.set_point_now(name, value)
            if loggers[name].read_trigged():
                print(name + ': ' + str(value))
                db_logger.save_point_now(name, value)
                loggers[name].clear_trigged()
def main():
    """ Main function """
    logging.basicConfig(filename="logger.txt", level=logging.ERROR)
    logging.basicConfig(level=logging.ERROR)

    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    adc_instance = ADCPi(bus, 0x68, 0x69, 18)

    pressurereader = PressureReader(adc_instance)
    pressurereader.daemon = True
    pressurereader.start()

    codenames = ['chemlab312_sample_storage_pressure']
    loggers = {}
    for i in range(0, 1):
        loggers[codenames[i]] = ValueLogger(pressurereader,
                                            comp_val=0.05,
                                            comp_type='log')
        loggers[codenames[i]].start()
    socket = DateDataPullSocket('chemlab312_sample_storage',
                                codenames,
                                timeouts=[2.0])
    socket.start()

    live_socket = LiveSocket('chemlab312_sample_storage', codenames)
    live_socket.start()

    db_logger = ContinuousDataSaver(
        continuous_data_table='dateplots_chemlab312',
        username=credentials.user,
        password=credentials.passwd,
        measurement_codenames=codenames)
    db_logger.start()

    time.sleep(5)

    while True:
        time.sleep(0.5)
        for name in codenames:
            value = loggers[name].read_value()
            socket.set_point_now(name, value)
            live_socket.set_point_now(name, value)
            if loggers[name].read_trigged():
                print(value)
                db_logger.save_point_now(name, value)
                loggers[name].clear_trigged()
Beispiel #8
0
def init_servos(address):
    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    pwm = PWM(bus, address)
    pwm.set_pwm_freq(60)
    pwm.output_enable()

    # cycle the arms on channels 0, 2, 4
    print('cycling through all valid positions')
    for x in (175, 300, 425, 550):
        pwm.set_pwm(0, 0, x)
        sleep(1)
        pwm.set_pwm(2, 0, x)
        sleep(1)
        pwm.set_pwm(4, 0, x)
        sleep(2)
    return pwm
def main():
    """ Main function """
    logging.basicConfig(filename="logger.txt", level=logging.ERROR)
    logging.basicConfig(level=logging.ERROR)

    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    adc_instance = DeltaSigma(bus, 0x68, 0x69, 18)

    tempreader = TemperatureReader(adc_instance)
    tempreader.daemon = True
    tempreader.start()

    codenames = ['cooling_water_hot', 'cooling_water_cold']
    loggers = {}
    for i in range(0, 2):
        loggers[codenames[i]] = ValueLogger(tempreader,
                                            comp_val=0.5,
                                            channel=i)
        loggers[codenames[i]].start()
    socket = DateDataPullSocket('hall_cooling_water_temp',
                                codenames,
                                timeouts=2.0)
    socket.start()

    live_socket = LiveSocket('hall_waterpressure', codenames)
    live_socket.start()

    db_logger = ContinuousDataSaver(continuous_data_table='dateplots_hall',
                                    username=credentials.user,
                                    password=credentials.passwd,
                                    measurement_codenames=codenames)
    db_logger.start()

    time.sleep(5)

    while tempreader.is_alive():
        time.sleep(0.25)
        for name in codenames:
            value = loggers[name].read_value()
            socket.set_point_now(name, value)
            live_socket.set_point_now(name, value)
            if loggers[name].read_trigged():
                print(value)
                db_logger.save_point_now(name, value)
                loggers[name].clear_trigged()
Beispiel #10
0
	def run(self):
		global mph
		global flag
		t1 = 0
		t2 = 0
		flagMine = 0
		diameter = 14     # need to find the actual diameter !!!

		i2c_helper = ABEHelpers()
		bus = i2c_helper.get_smbus()
		adc = ADCDifferentialPi(bus, i2cAddr1, i2cAddr2, bitRate)
		while True:
			c.acquire()
			if flag == 1:
				flag = 0
				voltage = adc.read_voltage( channel )               # voltage output from hall sensor (either a pos. or neg. value)
				curTime = time.time() - initTime                    # calculates the current time from time acc. minus time started with

				if voltage < 0.0 and flagMine == 0:                     # if voltage is neg. and we have not passed by the magnet yet
					flagMine = 1
					t1 = t2                                             # stores the previous curent time from curTime
					t2 = curTime                                        # stores the current time in curTime
					rps = 1/(t2 - t1)                                   # revolutions per second
					mph = rps * (math.pi) * diameter * (3600/63360)     # conversion from rps to miles per second
					#mph = rps*60

					#print( str(curTime) + "," + str(voltage) + "," + str(mph) )
					#text_file.write( str(curTime) + "," + str(voltage) + "," + str(mph) + "\n" )

				elif voltage < 0.0 and flagMine == 1:                   # else if voltage is neg. but we are currently still passing by the magnet
					#print( str(curTime) + "," + str(voltage) )
					#text_file.write( str(curTime) + "," + str(voltage) + "\n" )
					temp = 1

				else:                                               # else the voltage is positive (meaning the magnet is not next the the hall sensor)
					flagMine = 0
					#print( str(curTime) + "," + str(voltage) )
					#text_file.write( str(curTime) + "," + str(voltage) + "\n" )

				#mph = mph + 1
				c.notify_all()
			else:
				c.wait()
			c.release()
		text_file.close()	
def main():
    """ Main function """
    logging.basicConfig(filename="logger.txt", level=logging.ERROR)
    logging.basicConfig(level=logging.ERROR)

    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    adc_instance = ADCPi(bus, 0x68, 0x69, 18)
    pressurereader = PressureReader(adc_instance)
    pressurereader.daemon = True
    pressurereader.start()

    logger = ValueLogger(pressurereader, comp_val=0.5)
    logger.start()

    socket = DateDataPullSocket('hall_n5_argon_pressure',
                                ['n5_argon_pressure'],
                                timeouts=[1.0])
    socket.start()

    live_socket = LiveSocket('hall_n5_argon_pressure', ['n5_argon_pressure'],
                             2)
    live_socket.start()

    db_logger = ContinuousDataSaver(
        continuous_data_table='dateplots_hall',
        username=credentials.user,
        password=credentials.passwd,
        measurement_codenames=['n5_argon_pressure'])
    db_logger.start()

    time.sleep(2)

    while True:
        time.sleep(0.25)
        value = logger.read_value()
        socket.set_point_now('n5_argon_pressure', value)
        live_socket.set_point_now('n5_argon_pressure', value)
        if logger.read_trigged():
            print(value)
            db_logger.save_point_now('n5_argon_pressure', value)
            logger.clear_trigged()
Beispiel #12
0
def StrainGauge():
    text_file = open("strainGuage_Data.txt", "w")

    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    adc = ADCDifferentialPi(bus, i2cAddr1, i2cAddr2, bitRate)

    adc.set_pga(
        1)  # Set the gain of the PDA on the chip (Parameters: gain - 1,2,4,8)

    prev_voltage = 0

    for i in range(10000):
        voltage = adc.read_voltage(channel)  # voltage output from strain Gauge

        changeInVoltage = voltage - prev_voltage
        prev_voltage = voltage

        #print( str(changeInVoltage * 1000) )

        text_file.write(str(voltage) + "\n")
Beispiel #13
0
    def __init__(self,
                 bus=None,
                 address=None,
                 address2=None,
                 samplerate=None,
                 gain=None):
        from ABE_helpers import ABEHelpers
        from ABE_ADCDifferentialPi import ADCDifferentialPi

        if bus is None:
            i2c_helper = ABEHelpers()
            bus = i2c_helper.get_smbus()

        # Initialize the ADC device using the default addresses and sample rate 18.
        # Sample rate can be 12, 14, 16 or 18.
        self.adc = ADCDifferentialPi(bus,
                                     address=address,
                                     address2=address2,
                                     rate=samplerate)

        # Set amplifier gain to 8.
        if gain is not None:
            self.adc.set_pga(gain)
This example shows how to use the interrupt methods on the IO Pi.
The interrupts will be enabled and set so that a voltage applied to
pins 1 and 16 will trigger INT A and B respectively.
using the read_interrupt_capture or read_port methods will
reset the interrupts


Initialise the IOPi device using the default addresses and set the
output of bank 1 on IC1 to the input of bank 1 on IC2
"""
from ABE_helpers import ABEHelpers
from ABE_IoPi import IoPi
import time

i2c_helper = ABEHelpers()
newbus = i2c_helper.get_smbus()

bus1 = IoPi(newbus, 0x20)
bus2 = IoPi(newbus, 0x21)

# Set all pins on bus 2 to be inputs with internal pull-ups disabled.

bus2.set_port_pullups(0, 0x00)
bus2.set_port_pullups(1, 0x00)
bus2.set_port_direction(0, 0xFF)
bus2.set_port_direction(1, 0xFF)

# Set the interrupt polarity to be active high and mirroring disabled, so
# pins 1 to 8 trigger INT A and pins 9 to 16 trigger INT B
bus2.set_interrupt_polarity(1)
Beispiel #15
0
def hallSen(hallSensor_Num, adcChannel_Num, adcBitRate_Num, i2cAddr1_Num,
            i2cAddr2_Num, outputFile_Name, diameter_Num, hallSensorActive):
    # ADC Setup
    channel = 1  # analog channel number (1-8 inclusive)
    bitRate = 12  # programmable data rate
    # 18 (3.75 SPS) less per sec. but more
    # 16 (  15 SPS) --
    # 14 (	60 SPS) --
    # 12 ( 240 SPS) more per sec. but less accurate

    i2cAddr1 = 0x68  # these address are associated with the Address Config. 1
    i2cAddr2 = 0x69

    text_file = open("hallSensor_Data1.txt", "w")
    initTime = time.time()

    t1 = 0
    t2 = 0

    flag = 0
    diameter = 14  # need to find the actual diameter !!!

    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    adc = ADCDifferentialPi(bus, i2cAddr1, i2cAddr2, bitRate)

    global activeMphValues
    global flagThread

    global activeHallSensors
    activeHallSensors.append(hallSensorActive)

    mph = 0
    activeMphValues.append(mph)
    #activeMphValues[hallSensor_Num-1] = mph

    while activeHallSensors[hallSensor_Num - 1]:
        voltage = adc.read_voltage(
            channel
        )  # voltage output from hall sensor (either a pos. or neg. value)
        curTime = time.time(
        ) - initTime  # calculates the current time from time acc. minus time started with

        if voltage < 0.0 and flag == 0:  # if voltage is neg. and we have not passed by the magnet yet
            flag = 1
            t1 = t2  # stores the previous current time from curTime
            t2 = curTime  # stores the current time in curTime
            rps = 1 / (t2 - t1)  # revolutions per second
            activeMphValues[
                hallSensor_Num -
                1] = (rps * (math.pi) * diameter * (3600 / 63360)
                      ) / 11.5  # conversion from rps to miles per second
            #temp = rps * (math.pi) * diameter * (3600/63360)
            rpm = rps * 60
            #activeMphValues[hallsensor_Num-1] = rpm
            #mph = rps*60

            #print( str(curTime + "," + str(voltage) + "," + str(mph) )
            text_file.write(str(curTime) + "," + str(rpm) + "\n")
            text_file.flush()

        elif voltage < 0.0 and flag == 1:  # else if voltage is neg. but we are currently still passing by the magnet
            #print( str(curTime) + "," + str(voltage) )
            #text_file.write( str(curTime) + "," str(voltage) + "\n" )
            filler = 0

        else:  # else the voltage is positive (meaning the magnet is not next to the hall sensor)
            flag = 0
            #print( str(curTime) + "," + str(voltage) )
            #text_file.write( str(curTime) + "," + str(voltage) + "\n" )
            flag = 0  # added hopefully no problems, if problems comment this out

        #time.sleep( 0.0100 )

    text_file.close()
Beispiel #16
0
def hallSen():
    # ADC Setup
    channel = 1  # analog channel number (1-8 inclusive)
    bitRate = 12  # programmable data rate
    # 18 (3.75 SPS) less per sec. but more accurate
    # 16 (  15 SPS) --
    # 14 (  60 SPS) --
    # 12 ( 240 SPS) more per sec. but less accurate

    i2cAddr1 = 0x68  # these addresses are associated with the Address Config. 1
    i2cAddr2 = 0x69

    text_file = open("hallSensor_Data_1.txt", "w")
    initTime = time.time()

    text_file.write(str(globalValue))
    text_file.flush()

    global t1
    global t2
    flag = 0
    diameter = 14  # need to find the actual diameter !!!

    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    adc = ADCDifferentialPi(bus, i2cAddr1, i2cAddr2, bitRate)

    global mph
    global flagThread
    global killH

    while True:
        if killH == True:
            text_file.close()
            time.sleep(10)
        else:
            voltage = adc.read_voltage(
                channel
            )  # voltage output from hall sensor (either a pos. or neg. value)
            curTime = time.time(
            ) - initTime  # calculates the current time from time acc. minus time started with

            if voltage < 0.0 and flag == 0:  # if voltage is neg. and we have not passed by the magnet yet
                flag = 1
                t1 = t2  # stores the previous curent time from curTime
                t2 = curTime  # stores the current time in curTime
                rps = 1 / (t2 - t1)  # revolutions per second
                flagThread = 1
                mph = rps * (math.pi) * diameter * (
                    3600 / 63360)  # conversion from rps to miles per second
                rpm = rps * 60
                flagThread = 0
                #mph = rps*60

                #print( str(curTime) + "," + str(voltage) + "," + str(mph) )
                text_file.write(str(curTime) + "," + str(rpm) + "\n")
                text_file.flush()

            elif voltage < 0.0 and flag == 1:  # else if voltage is neg. but we are currently still passing by the magnet
                #print( str(curTime) + "," + str(voltage) )
                #text_file.write( str(curTime) + "," + str(voltage) + "\n" )
                filler = 0

            else:  # else the voltage is positive (meaning the magnet is not next the the hall sensor)
                flag = 0
                #print( str(curTime) + "," + str(voltage) )
                #text_file.write( str(curTime) + "," + str(voltage) + "\n" )

                #time.sleep( 0.0100 )

    text_file.close()
Beispiel #17
0
def init_nox():
    """ init the sensor reader """
    i2c_helper = ABEHelpers()
    bus = i2c_helper.get_smbus()
    adc = ADCPi(bus, 0x6A, 0x6B, 12)
    return adc
    def __init__(self, master):
        self.i2c_helper = ABEHelpers()
        self.newbus = self.i2c_helper.get_smbus()
        self.bus2 = IoPi(
            self.newbus, 0x21
        )  # create an instance of Bus 2 which is on I2C address 0x21 by default
        self.bus2.set_port_direction(
            0, 0x00)  # set pins 1 to 8 to be outputs and turn them off
        self.bus2.write_port(0, 0x00)

        self.bus2.set_port_direction(
            1, 0x00)  # set pins 9 to 16 to be outputs and turn them off
        self.bus2.write_port(1, 0x00)

        frame = Frame(master)  # create a frame for the GUI
        frame.pack()

        # create 16 buttons which run the togglepin function when pressed
        self.button = Button(frame,
                             text="Pin 1",
                             command=lambda: self.togglepin(1))
        self.button.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 2",
                             command=lambda: self.togglepin(2))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 3",
                             command=lambda: self.togglepin(3))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 4",
                             command=lambda: self.togglepin(4))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 5",
                             command=lambda: self.togglepin(5))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 6",
                             command=lambda: self.togglepin(6))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 7",
                             command=lambda: self.togglepin(7))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 8",
                             command=lambda: self.togglepin(8))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 9",
                             command=lambda: self.togglepin(9))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 10",
                             command=lambda: self.togglepin(10))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 11",
                             command=lambda: self.togglepin(11))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 12",
                             command=lambda: self.togglepin(12))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 13",
                             command=lambda: self.togglepin(13))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 14",
                             command=lambda: self.togglepin(14))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 15",
                             command=lambda: self.togglepin(15))
        self.slogan.pack(side=LEFT)

        self.slogan = Button(frame,
                             text="Pin 16",
                             command=lambda: self.togglepin(16))
        self.slogan.pack(side=LEFT)
Beispiel #19
0
import RPi.GPIO as GPIO
import LCD1602 
from ABE_ADCPi import ADCPi             	#import the ADCPi library
from ABE_helpers import ABEHelpers      	#import ABEHelpers for smbus
import time		                	#import time module for delay
import smbus		                	#import smbus for i2c
LCD1602.init(0x27, 1)                   	#Assign LCD i2c address

GPIO.setwarnings(False)                 #remove uncecessary warnings
GPIO.setmode(GPIO.BCM)                  #setting pin mode to BCM

i2c_helper=ABEHelpers()	       #Creating instance of ABEHelpers() for i2c_bus object
bus=i2c_helper.get_smbus()	 	#Creating instance of i2c_bus
ADC=ADCPi(bus, 0X69, 0X6f, 18)   	#Set the i2c configuration address and bit rate
time.sleep(0.2)
#########

#Keypad input/output pins
GPIO.setup(19, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
GPIO.setup(20, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
GPIO.setup(21, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
GPIO.setup(22, GPIO.IN, pull_up_down = GPIO.PUD_UP) 

GPIO.setup(23, GPIO.OUT) 
GPIO.setup(24, GPIO.OUT) 
GPIO.setup(25, GPIO.OUT) 
GPIO.setup(26, GPIO.OUT)

#Initializing the GPIO pins for Ultrasound, Buzzer, motion sensor, and LED
GPIO.setmode(GPIO.BCM) 
TRIG=13 #ultrasonic