from startup import startup from ssd_functions import ssd_number from ssd_functions import ssd_letter import time from DesignSpark.Pmod.HAT import createPmod import RPi.GPIO as GPIO GPIO.setwarnings(False) GPIO.setmode(GPIO.BCM) therm = createPmod("TC1", "JBA") red = 21 yellow = 20 green = 16 GPIO.setup(red, GPIO.OUT) GPIO.setup(yellow, GPIO.OUT) GPIO.setup(green, GPIO.OUT) aa = 4 ab = 17 ac = 27 ad = 22 ae = 5 af = 6 ag = 13 cat = 19 GPIO.setup(aa, GPIO.OUT)
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2017 RS Components Ltd # SPDX-License-Identifier: MIT License """ Print the celsius reading out. """ from DesignSpark.Pmod.HAT import createPmod import time if __name__ == '__main__': therm = createPmod('TC1', 'JBA') time.sleep(0.1) try: while True: cel = therm.readCelcius() print(cel) #intn = therm.readInternal() #print(intn) time.sleep(0.8) except KeyboardInterrupt: pass finally: therm.cleanup()
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2017 RS Components Ltd # SPDX-License-Identifier: MIT License """ Read current and print out milliamps. """ from DesignSpark.Pmod.HAT import createPmod import time if __name__ == '__main__': isens = createPmod('ISNS20', 'JBA') time.sleep(0.1) try: while True: mA = isens.readMilliAmps() print(mA) time.sleep(0.8) except KeyboardInterrupt: pass finally: isens.cleanup()
""" Print a continous sound level reading out. """ from DesignSpark.Pmod.HAT import createPmod import time s = ':' lut = [s] for i in range(128): s+=':' lut.append(s) if __name__ == '__main__': mic = createPmod('MIC3','JBA') time.sleep(0.1) try: while True: int = mic.readIntegerValue() #print(int) print(lut[int>>5]) snd = mic.readPhysicalValue() #print(snd) #time.sleep(0.01) except KeyboardInterrupt: pass finally: mic.cleanup()
right = left + scale bottom = top + scale draw.rectangle((left, top, right, bottom), fill="white", outline="black") if i == 0: w, h = draw.textsize("Game of Life") left = (device.width - w) // 2 top = (device.height - h) // 2 draw.rectangle((left - 1, top, left + w + 1, top + h), fill="black", outline="white") draw.text((left + 1, top), text="Game of Life", fill="white") if i == 0: time.sleep(3) board = iterate(board) if __name__ == "__main__": try: oled = createPmod('OLEDrgb', 'JA') device = oled.getDevice() main() except KeyboardInterrupt: pass
state = redred(x="EV") while state: state = redred(x="EV") #!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2017 RS Components Ltd # SPDX-License-Identifier: MIT License """ Read ADC channel A1 and print volts out. """ from DesignSpark.Pmod.HAT import createPmod import time if __name__ == '__main__': adc = createPmod('AD1', 'JBA') time.sleep(0.1) try: while True: volts = adc.readA1Volts() print(volts) #val = adc.readA1() #print(val) time.sleep(0.8) except KeyboardInterrupt: pass finally: adc.cleanup()
from DesignSpark.Pmod.HAT import createPmod import thingspeak import time from ssd_num_function import ssd_number # imports seven segment display script from ssd_num_function import print_therm from LED_therm_function import LED_therm # imports LED for thermometer script from thingspeak_temp import measure # imports publish to thingspeak script from pir_function import pir from hello_function import ssd_letter channel_id = 1153269 # for thingspeak write_key = "4ZVTF64GKE82K42Q" # for thingspeak read_key = "QT70XUM9SQCCO2A4" # for thingspeak therm = createPmod("TC1", "JBA") # assigner Pmod værdi GPIO.setwarnings(False) # fjerner warnings GPIO.setmode(GPIO.BCM) # krav for breadboard bt0 = 18 bt1 = 23 bt2 = 25 bt3 = 12 GPIO.setup(bt0, GPIO.IN) GPIO.setup(bt1, GPIO.IN) GPIO.setup(bt2, GPIO.IN) GPIO.setup(bt3, GPIO.IN)
# -*- coding: utf-8 -*- # Copyright (c) 2017 RS Components Ltd # SPDX-License-Identifier: MIT License """ Spin motor forwards then backwards. Ramp speed up and then down in forward direction. Ramp speed up and then down in reverse direction. """ from DesignSpark.Pmod.HAT import createPmod import time if __name__ == '__main__': motor = createPmod('HB3','JAA') try: while True: print('fwd') motor.forward(20) time.sleep(2) motor.stop() time.sleep(2) print('rev') motor.reverse(20) time.sleep(1) motor.stop() time.sleep(2)