antitheft159 commited on
Commit
420ca3c
1 Parent(s): 778b471

Upload nadereren_195.py

Browse files
Files changed (1) hide show
  1. nadereren_195.py +54 -0
nadereren_195.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """naderEren.195
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1DpxhB_ApIH6oxffzDMDc5GYgn_PqdFRB
8
+ """
9
+
10
+ import RPi.GPIO as GPIO
11
+ from time import sleep
12
+ dt=.1
13
+ b1=40
14
+ b2=38
15
+ b1State=1
16
+ b1StateOld=1
17
+ b2State=1
18
+ b2StateOld=1
19
+ LEDPin=37
20
+ DC=99
21
+ GPIO.setmode(GPIO.BOARD)
22
+ GPIO.setup(b1,GPIO.IN,pull_up_down=GPIO.PUD_UP)
23
+ GPIO.setup(b2,GPIO.IN,pull_up_down=GPIO.PUD_UP)
24
+ GPIO.setup(LEDPin,GPIO.OUT)
25
+ myPWM=DPIO.GWM(LEDPin,100)
26
+ myPWM.start(DC)
27
+ BP=10
28
+
29
+ try:
30
+ while True:
31
+ b1State=GPIO.input(b1)
32
+ b2State=GPIO.input(b2)
33
+ if b1StateOld==0 and b1State==1:
34
+ BP=BP-1
35
+ DC=(1.5849)^BP
36
+ print('Dim Event')
37
+ if b2StateOld==0 and b2State==1:
38
+ BP=BP+1
39
+ DC=(1.5849)^BP
40
+ print('Bright Event')
41
+ if DC>99:
42
+ DC=99
43
+ if DC<0
44
+ DC=0
45
+ print(DC)
46
+ myPWM.ChangeDutyCycle(DC)
47
+ b1StateOld=b1State
48
+ b2StateOld=b2State
49
+ sleep(dt)
50
+
51
+ except keyboardInterrupt:
52
+ myPWM.stop()
53
+ GPIO.clenup()
54
+ print('GPIO Ready to Perform')