#!/usr/bin/python # -*- coding: utf-8 -*- import time import math from logo import print_seeedstudio import grove_i2c_adc import Adafruit_BBIO.GPIO as GPIO BUZZER = "P9_22" # GPIO P9_22 GPIO.setup(BUZZER, GPIO.OUT) # The threshold to turn the buzzer on 28 Celsius THRESHOLD_TEMPERATURE = 28 adc = grove_i2c_adc.I2cAdc() # The argument in the read_temperature() method defines which Grove board(Grove Temperature Sensor) version you have connected. # Defaults to 'v1.2'. eg. # temp = read_temperature('v1.0') # B value = 3975 # temp = read_temperature('v1.1') # B value = 4250 # temp = read_temperature('v1.2') # B value = 4250 def read_temperature(model = 'v1.2'): "Read temperature values in Celsius from Grove Temperature Sensor" # each of the sensor revisions use different thermistors, each with their own B value constant if model == 'v1.2': bValue = 4250 # sensor v1.2 uses thermistor ??? (assuming NCP18WF104F03RC until SeeedStudio clarifies) elif model == 'v1.1': bValue = 4250 # sensor v1.1 uses thermistor NCP18WF104F03RC else: bValue = 3975 # sensor v1.0 uses thermistor TTC3A103*39H
import time #from logo import print_seeedstudio import grove_chainable_rgb_led from adxl345 import ADXL345 import grove_i2c_adc CLK_PIN = "P9_22" DATA_PIN = "P9_21" NUMBER_OF_LEDS = 1 if __name__ == "__main__": adxl345 = ADXL345() rgb_led = grove_chainable_rgb_led.ChainableLED(CLK_PIN, DATA_PIN, NUMBER_OF_LEDS) button = grove_i2c_adc.I2cAdc() Red = 255 Green = 255 Blue = 255 while True: try: if button.read_adc() >= 2000: axes = adxl345.getAxes(True) Red = 128 + 128 * axes['x'] Green = 128 + 128 * axes['y'] Blue = 128 + 128 * axes['z'] print " x = %.3fG" % (axes['x']) print " y = %.3fG" % (axes['y']) print " z = %.3fG" % (axes['z']) print "Red = %d " % Red