Jump to content

NodeMCU Projects: Difference between revisions

Line 522:
d.marquee("This code is working fine now...")
</syntaxhighlight>
 
 
== Display Info using Urequests ==
 
<syntaxhighlight lang="python">
from machine import Pin, SPI
import max7219, utime
import urequests as requests
 
spi = SPI(1, 10000000)
d = max7219.Max7219(32, 8, spi, Pin(15), False)
 
cntry = ["India", "China", "Italy", "Iran", "Canada", "US", "Ireland", "Germany"]
 
while True:
for i in cntry:
link = 'http://coronavirus-19-api.herokuapp.com/countries/%s' %i
res = requests.get(url=link)
data = res.json()
d.marquee(str(data["country"]) + " - Cases: " + str(data["cases"]) + " Recovered: " + str(data["recovered"]) + " Critical: " + str(data["critical"]) + " Deaths: " + str(data["deaths"]) + " TodayCases: " + str(data["todayCases"]) + " TodayDeaths: " + str(data["todayDeaths"]))
</syntaxhighlight>
 
 
 
 
<br />
Cookies help us deliver our services. By using our services, you agree to our use of cookies.