Click here to Skip to main content
15,439,117 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to turn on my LED connected to arduino board once it satisfies any condition provded in my python program. 

These are the conditions:

Temperature < 28 , Humidity < 60 , Moisture> 179:

Observation= 'Temperature & Humidity is less.'

Temperature > 28 , Humidity < 60 , Moisture< 179:

Observation= 'Humidity & Moisture is less.'

Temperature < 28 , Humidity > 60 , Moisture < 179:

Observation = 'Temperature & Moisture is less.'

I want the LED to turn on when the output is : '<pre>Humidity & Moisture is less.
I have created a code to user input the data and predict the value:

x=int(input("Enter the tmp:"))
y=int(input("Enter the hum:"))
z=int(input("Enter the moist:"))
my_list =[x,y,z]
y_pred = loaded_model.predict(xc)

Once we enter the inputs the ouput will get displayed through 'y pred' respective to the condition provided.

I want the led to turn on when y pred gives an output as 'Temperature & Moisture is less.'

What will be the python code to turn on the led based on this?

What I have tried:

I have tried :
from pyfirmata import util, Arduino
import time

def blink(b_time):
    board = Arduino('COM5')
    it = util.Iterator(board)

    led_13 = board.get_pin('d:13:o')
    while True:
        print('Led ON')
        print('Led OFF')

if __name__ == '__main__':

inorder to check whether the led will turn on or not. And the led turned on. Now I want to know how can I turn the LED based on the conditions provided above.
Updated 22-Nov-21 20:25pm

1 solution

So compare the values, and do it. You have the "on" and "off" code - so all you need it the conditional stuff: Python Conditions[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900