-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraspberrypi.py
87 lines (82 loc) · 7.05 KB
/
raspberrypi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import RPi.GPIO as GPIO
import time
import urllib
import sys
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(35,GPIO.OUT)
GPIO.setup(33,GPIO.OUT)
GPIO.setup(29,GPIO.OUT)
GPIO.setup(31,GPIO.OUT)
GPIO.setup(32,GPIO.OUT)
GPIO.setup(36,GPIO.OUT)
GPIO.setup(38,GPIO.OUT)
GPIO.setup(40,GPIO.OUT)
GPIO.setwarnings(False)
GPIO.output(35,GPIO.LOW)
GPIO.output(33,GPIO.LOW)
GPIO.output(31,GPIO.LOW)
GPIO.output(29,GPIO.LOW)
GPIO.output(32,GPIO.LOW)
GPIO.output(36,GPIO.LOW)
GPIO.output(38,GPIO.LOW)
GPIO.output(40,GPIO.LOW)
#GPIO.setup(7,GPIO.LOW);
current = GPIO.input(7)
current_state = 0
previous_state = 0
choc_present = 0
choc_last = 0;
choc_counter =0
a =0
pin=29
count =0;
#url_code = "";
#url = "http://bhawesh.com/abcd/verify.php?code="
random_codes =
[8886,8743,2269,2105,5821,7433,1039,5093,4096,5152,6648,7419,8630,8581,9494,2509,8437,6589,5179,2841,3838,9686,4678,6683,6267,5324,8807,4822,7835,4735,1582,8770,2106,6797,5545,8476,2091,4452,1927,6393,2929,8676,2202,8743,6805,6197,9222,3969,1993,3187,9690,6881,9942,1199,8335,9385,3281,6133,4717,3778,7072,2903,8844,1520,1253,9246,3091,2552,9198,6691,4721,1654,8614,9794,8065,7926,5538,5709,5129,2764,1580,6908,7869,8548,3093,5751,3623,7769,7995,1194,2640,9666,5014,7217,1114,8688,1300,7186,6920,3063,9929,5288,2280,9546,1719,7802,8482,3134,7828,9272,8992,6923,2990,2627,5662,9374,5098,4135,5904,6636,2423,8926,3576,4186,6305,7832,4831,6574,3892,3375,3767,6246,4610,5793,6733,4588,6556,8567,6424,6867,6874,1956,6628,5089,8706,7606,2480,5668,2341,8856,9524,6816,3425,6558,3689,1515,5654,5047,4836,9667,9785,6455,4613,3887,8320,6297,8268,5083,7284,3412,6934,1324,9284,6219,8052,6212,1258,1106,8725,9304,4986,9069,8817,7784,5830,5010,1313,8950,1358,4508,2966,1865,2730,2289,7145,6877,5996,4043,4537,7948,9288,4516,7020,8517,6895,2120,1039,9710,6005,3326,9338,5221,1747,2202,2856,1357,9100,7084,2273,4449,6265,4574,4971,9219,6340,7245,4746,2652,2194,7860,7236,4214,7269,7032,6817,7827,5915,2491,3639,7571,7370,2819,5804,7761,1538,8099,3587,7521,4287,1542,5288,5134,8605,7321,2594,8637,5261,4825,9520,4772,2818,2241,7745,4570,5461,7217,3704,3584,6525,3705,7592,8691,7903,4732,2289,8853,5447,3094,4627,8630,4040,2921,5255,8931,5542,1852,8395,5301,5700,6326,5869,3086,1186,8078,8131,5876,7491,4717,3407,6531,6291,5181,2285,8098,1765,6534,2151,2050,4511,3027,9467,8880,9962,9711,3117,7600,7177,6839,2243,9738,8992,1398,7768,3118,3670,9222,1680,4509,6011,2497,7769,4768,6032,6094,7740,5419,6909,7299,2051,6982,6225,6013,8307,2157,9904,2079,6206,9036,4334,3926,6639,6138,1966,6289,2394,7235,1017,9291,9407,2489,1252,1780,2990,6095,5812,9731,9312,3814,7661,8246,5377,4989,2238,1370,1903,1786,1042,8853,5841,4131,4240,8373,2805,2598,4601,2709,7116,5541,1444,1123,2355,1079,3952,1372,8726,6142,5989,1956,3779,4403,3896,9378,3391,3335,5075,3059,4991,4421,7914,2053,3530,9728,1884,7160,6161,1430,6652,6314,3637,1875,1804,6066,6176,3596,3325,1167,7565,8444,7424,1832,1274,3377,3062,4378,3503,4831,2815,4085,6343,8078,4247,7689,3254,8679,7321,5541,6467,7026,7415,7499,7667,1634,3270,1520,1347,7254,5756,1500,8088,4968,8129,8481,3080,5758,7221,9044,6832,2126,1696,6737,8754,7791,9107,8442,3615,7599,9340,5546,1038,8175,2572,2781,9740,6652,6799,6971,8974,2456,6453,4129,7021,1778,9252,4824,3044,9333,7874,5461,4467,8362,4753,2772,9746,3884,7551,8594,1984,6639,1803,1191,2219,1208,8986,9267,1819,7967,6406,8445,2630,6764,3076,9239,5907,4612,6266,8087,4357,5385,7301,6406,5327,2912,3724,4539,7731,1253,4917,6582,8254,5981,2647,5608,7206,7169,4242,3465,6175,1495,6299,7678,1508,4996,1339,6660,1274,5434,8702,7251,1246,8476,6257,7635,5863,4563,2944,3948,3559,5391,9711,9772,6853,9880,9244,9441,5005,1568,9983,7566,7108,5969,1336,4099,1396,3132,9799,3866,7298,1436,8801,7939,5125,8167,6329,9897,2096,9335,3239,7381,5079,6695,5625,4758,9584,7438,2494,9114,9725,6312,8261,7788,1797,4128,2876,4446,7367,3210,8690,2197,4927,6970,8497,1937,5622,5623,4795,2771,9725,7669,6317,7128,3044,8644,3206,5984,2753,3255,2816,1189,5738,4492,5721,7116,8704,2227,5487,4429,7730,7027,3689,6082,7279,5221,2056,6193,3146,4362,2400,5017,1432,8766,3325,6349,9780,6969,8685,2577,3217,4780,7960,1992,3523,1107,7693,1359,2722,7036,8604,8536,8818,6455,2849,3254,9596,3935,7774,2485,5062,1785,6131,5704,7760,3426,6984,1702,1001,6782,4942,9719,1621,7767,7671,5784,4244,1735,9606,3567,3060,6853,8476,1439,4494,7077,4197,9442,5862,9010,9086,8944,7769,3496,8130,7211,5911,6219,5455,4586,4785,3314,5765,5870,9773,8253,8901,4631,4166,1411,7751,1153,1746,9907,8081,2898,3837,5769,3570,9103,3105,6402,4907,9328,9209,9247,9513,5133,9087,2673,4422,3725,7787,4261,4050,1097,2820,3722,7509,1096,3233,3064,4555,6884,1902,7832,7770,8344,5016,1744,5761,4910,5914,5234,3075,8432,5163,2779,8491,5919,2762,5480,2502,2432,7695,5327,3187,2345,5395,3625,4650,4829,2899,6299,3970,2102,7672,4255,7773,5374,5558,9866,2240,3106,3836,1384,2007,5046,8323,6770,2216,1908,8873,4491,8370,7894,1576,7986,5870,5408,5650,2567,7654,4604,9979,3507,4353,2160,4468,5617,3227,1648,7970,2501,8273,1593,8613,1396,3405,4066,9270,1687,7107,9770,2041,5254,9619,3494,8254,2092,9480,6971,2965,3350,8157,3461,3495,5192,6946,8231,7920,8821,8396,9819,8273,6475,6391,3137,6599,6377,7930,2267,7630,9946,2581,2182,9274,1774,7824,9393,8915,2137,1463,1277,3416,4041,2815,4954,3340,7479,4929,1400,7644,9556,3765,4683,1421,5683,5274,7024,6722,8026,5680,1168,6346,9603,7216,1459,5084,8208,2417,6886,6486,4425,2173,3422,8260,8362,5275,1187,7689,2791,5433,1368,1268,9373,2759,2299,9769,2507,6246,4820,6405,3681,4755,6841,7071,5972,3027,4625,1906,2865,5277,7426,9618,3050,8098,7769,2518,6217,6032,3399,8138,7693,1545,1003,2158,3914,2260,6786,6597,1376,8729,8314,1152,7640,8049,5314,9049,3791,6193,2536,2176,5109,2692,7588,2452,5365,7521,1239,8102,7962,3193,2030,1022,7581,8536,9644,6830,7406,2735,8549,9799]
try:
while(True):
time.sleep(0.01)
#a = raw_input();
#url_code =url + str(a);
#print url_code
#response = urllib.urlopen(url_code).read()
#print response
num = int(raw_input ("Type your secret code : "))
#search = open("rand_write.txt","r")
a=0;
if num in random_codes:
a=1;
print'code found'
random_codes.remove(num)
if(a==1):
GPIO.output(pin,GPIO.HIGH)
print "waiting"
print pin;
while(True):
time.sleep(0.01)
if GPIO.input(7) == 1:
time.sleep(0.01)
print "goodie ready"
GPIO.output(pin ,GPIO.LOW)
print 'Bhawesh'
time.sleep(1)
choc_counter = choc_counter + 1
print "chocolates removed" + str(choc_counter)
break
if(choc_counter%4 == 0):
pin = pin +1;
if(pin==30):
pin = 32
if(pin == 33):
pin = 36
#if(pin ==37):
#pin =40
while(pin==37):
print"Need Refuelling"
else:
print'code not found'
except KeyboardInterrupt:
GPIO.cleanup();