Skip to content

Commit 0a2cedb

Browse files
committed
small changes
1 parent a4bbb2e commit 0a2cedb

File tree

5 files changed

+74
-49
lines changed

5 files changed

+74
-49
lines changed

api_weather.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Python program to find current weather details of any city using openweathermap api
2+
import requests, json
3+
api_key = "b03aae2dd0d2c016e48d6fc50ec429f2"
4+
base_url = "http://api.openweathermap.org/data/2.5/weather?"
5+
city_name = input("Enter city name : ")
6+
7+
complete_url = base_url + "appid=" + api_key + "&q=" + city_name + "&units=metric"
8+
response = requests.get(complete_url)
9+
10+
x = response.json()
11+
if x["cod"] != "404":
12+
13+
y = x["main"]
14+
15+
current_temperature = y["temp"]# [] is keys() method to call/add something
16+
current_pressure = y["pressure"]
17+
18+
current_humidiy = y["humidity"]
19+
20+
z = x["weather"]
21+
22+
weather_description = z[0]["description"]
23+
24+
print(" Temperature (in celsius unit) = " +
25+
str(current_temperature) +
26+
"\n atmospheric pressure (in hPa unit) = " +
27+
str(current_pressure) +
28+
"\n humidity (in percentage) = " +
29+
str(current_humidiy) +
30+
"\n description = " +
31+
str(weather_description))
32+
else:
33+
print(" City Not Found ")
34+
#Arduino program to print temperature on lcd.
35+
#from pyfirmata import Arduino, util
36+
import serial
37+
import time
38+
39+
s = serial.Serial("COM4", 9600) #port is 11 (for COM12, and baud rate is 9600
40+
time.sleep(2) #wait for the Serial to initialize
41+
s.write('Ready...')
42+
while True:
43+
str1 = current_temperature
44+
45+
s.write(str1)

ard_test.py

-14
This file was deleted.

blinkled.py

-17
This file was deleted.

led_pwm_controlled.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pyfirmata import Arduino,util
2+
import time
3+
4+
board = Arduino("COM4")
5+
it = util.Iterator(board)
6+
it.start()
7+
8+
led = board.get_pin("d:9:o")
9+
10+
# for a in range(0,255):
11+
# led.write()
12+
# time.sleep(0.8)
13+
14+
# for a in range(255,0):
15+
while True:
16+
a = 0
17+
while a<=255:
18+
led.write(a)
19+
time.sleep(0.008)
20+
a+=1
21+
while a>=0:
22+
led.write(a)
23+
time.sleep(0.008)
24+
a-=1
25+
time.sleep(0.9)
26+
board.exit()
27+
28+
29+

switch_led.py

-18
This file was deleted.

0 commit comments

Comments
 (0)