Hello,
I am trying to do an if statement. I am getting a error [quote]Operator ‘<’ cannot be applied to operands of type ‘string’ and 'string[/quote] How do I use the < operator in this case?
Thanks,
I am a beginner.
Sensor Page: http://code.tinyclr.com/project/289/dht11---temperature-and-humidity-sensor/
namespace Sensor Test
{
public class Program
{
public static void Main()
{
DHT11 MyDHT11 = new DHT11((Cpu.Pin)FEZ_Pin.Digital.Di6, (Cpu.Pin)FEZ_Pin.Digital.Di7);
if (MyDHT11.Humidity.ToString() < "26")
}
}
}
DHT11 MyDHT11 = new DHT11((Cpu.Pin)FEZ_Pin.Digital.Di6, (Cpu.Pin)FEZ_Pin.Digital.Di7);
while (true)
{
if (MyDHT11.ReadSensor())
{
int x = int.Parse(MyDHT11.Humidity.ToString());
if (x < "26")
Debug.Print("The humidity is less than 26");
else
Debug.Print("The humidity is more than 26");
}
else
Debug.Print("DHT11 Error : " + MyDHT11.LastError);
why all the fuzz with that conversion to int’s or strings??
The driver returns a float so you can just do:
DHT11 MyDHT11 = new DHT11((Cpu.Pin)FEZ_Pin.Digital.Di6, (Cpu.Pin)FEZ_Pin.Digital.Di7);
while (true)
{
if (MyDHT11.ReadSensor())
{
if (MyDHT11.Humidity < 26f)
Debug.Print("The humidity is less than 26");
else
Debug.Print("The humidity is more than 26");
}
else
Debug.Print("DHT11 Error : " + MyDHT11.LastError);