NodeMCU Projects: Difference between revisions
Content added Content deleted
Line 522: | Line 522: | ||
d.marquee("This code is working fine now...") |
d.marquee("This code is working fine now...") |
||
</syntaxhighlight> |
</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 /> |
<br /> |