Étape 4: Étape 4: programmation votre Edison
moment de l’importation
importer des mathématiques
demandes d’importation
importations mraa import pyupm_i2clcd lcd
ratio de DEF (_value, from_min = 162, from_max = 299, to_min = 0. 0, to_max = 100.0): retour (flotteur (_value - from_min) * (to_max - to_min) / (from_max - from_min) + to_min)
pin = mraa. AIO(0) myLcd = lcd. Jhd1313m1 (0, 0x3E, 0x62) myLcd.setColor (0, 255, 128) while True : #url = « http://192.128.0.148/?reading=%d » #url = 'http://127.0.0.1:5000/?reading=%d' url = 'http://ws.pinewoods.com.br/api?reading=%d' lecture = 0 try : lire = pin.read() requests.post (url % lisant) #requests.post (url % 666) # Debug sauf Exception comme e: e impression
capteur de myLcd.setCursor (0, 0) = "capteur: %d ' % myLcd.write(sensor) capteur impression de lecture
myLcd.setCursor (1, 0) #distance = niveau de 87.09576644*math.exp(-0.004870217643*reading) = ratio(reading) myLcd.write(' ') # myLcd.setCursor propre (1, 0) nivel = ' Nivel : %.2f %%' myLcd.write(nivel) % (niveau) imprimer nivel
Time.Sleep(10)