-2

im doing a project about temperature and humidify control system. Im using skfuzzy as tool. I met some errors, after i try to edit with my own preference.

fanspeed = ctrl.ControlSystemSimulation(fanspeed_ctrl)

fanspeed.input['temperature'] = 40
fanspeed.input['humidify'] = 10

fanspeed.compute()
fanspeed.output['fan']
fan.view(sim=fanspeed)
print("Fan speed =",fanspeed.output['fan'])

Code above is working well but when i want it to accept user input instead of put the input in the code, so i try to change like this

fanspeed = ctrl.ControlSystemSimulation(fanspeed_ctrl)

temp = input("temp=")
hum = input("hum=")
fanspeed.input['temperature'] = temp
fanspeed.input['humidify'] = hum
fanspeed.compute()
fanspeed.output['fan']
fan.view(sim=fanspeed)
print("Fan speed =",fanspeed.output['fan'])

Anyone can give some advice will be nice :D Thanksssss

Sam
  • 19
  • 5

2 Answers2

0

User input is str type. use temp = int(input("temp=")) and hum = int(input("hum="))

Tamir
  • 1,224
  • 1
  • 5
  • 18
  • Wow that was a quick response, thanks for the help, wish you have a nice day man, really appreciate it :D – Sam May 01 '21 at 10:12
0
temp = int(input("temp="))
hum = int(input("hum="))
fanspeed.input['temperature'] = temp
fanspeed.input['humidify'] = hum
fanspeed.compute()
fanspeed.output['fan']
fan.view(sim=fanspeed)
print("Fan speed =",fanspeed.output['fan'])

The input function returns a string. What you need is an int. That's why the first example is working since you are assigning an int to the temp and hum variables and the second doesn't because you are assigning a str to it.

basilisk
  • 1,156
  • 1
  • 14
  • 34