No video

How to use Arduino Digital Write and "If" Statements

Пікірлер: 6

  • @pacomacaw2456
    @pacomacaw24563 жыл бұрын

    Really surprised that you are not getting more likes and subscriptions. Your teaching method works so well...at least for me. As mentioned by someone else the code screen is very small and hard to read. Also I would appreciate line numbers, but no big deal. Well done!

  • @TheBoredRobotLLC

    @TheBoredRobotLLC

    3 жыл бұрын

    I appreciate the feedback. For my future tutorials, I'll make the Arduino sketch interface bigger.

  • @msh2253
    @msh2253 Жыл бұрын

    Many thanks 🙏

  • @TheBoredRobotLLC

    @TheBoredRobotLLC

    Жыл бұрын

    I'm glad it helped!

  • @andrew7569
    @andrew75698 ай бұрын

    Sorry but do you think you could help me analyze why my LED's aren't coming on with my if statements? #include "Wire.h" #include "LCD_I2C.h" // Include the LiquidCrystal library. #include "DHT.h" // Include the DHT library. #define DHTPIN 8 // Set the DHT Pin. #define DHTTYPE DHT22 // Set the DHT type. LCD_I2C lcd (0x27); // Creates a LiquidCrystal object. Parameters: (RS, Enable (E), d4, d5, d6, d7). DHT dht(DHTPIN, DHTTYPE); // Creates a DHT object. Parameters: (DHT Pin, DHT Type). const int yellowLED = 10; // Adds a led light (in that case, it is yellow) to pin 9. const int blueLED = 11; // Adds a led light (in that case, it is blue) to pin 10. const int whiteLED = 12; // Adds a led light (in that case, it is white) to pin 11. int fan = 3; // Fresh Air Exchange Fan. int humidity = 5; //Humidifier disk. int fae = 4; void setup() { pinMode(10, OUTPUT); pinMode(11, OUTPUT); pinMode(12, OUTPUT); pinMode(4, OUTPUT); lcd.begin(); // Initializes the interface to the LCD screen, and specifies the dimensions (width and height) of the display. lcd.setCursor(0, 0); // Set the cursor to column 0, line 0. lcd.backlight(); dht.begin(); //digitalWrite(blueLED,HIGH); //digitalWrite(yellowLED,HIGH); //digitalWrite(whiteLED, HIGH); //analogWrite(humidity, 255); //analogWrite(fae, 255); //analogWrite(fan, 255); lcd.print("Temperature:"); // Print "Temperature:" on LCD Screen. lcd.setCursor(0, 1); // Set the cursor to column 0, line 1. lcd.print("Humidity :"); // Print "Humidity:" on LCD Screen. } void loop() { float T = dht.readTemperature(true); // Read temperature in Celsius. If you want the Temperature in Fahrenheit, simply add "true" between the parentheses ==> float T = dht.readTemperature(True); float H = dht.readHumidity(); // Read humidity in percentage. if (isnan(H) && isnan(T)) { // See if H (the Humidity variable) is NaN (Not A Number) && (Logical AND) See if T (the Temperature variable) is NaN to show error. lcd.print("ERROR"); // Print error where there's the error. return; // Repeat the process with each update (each second). } if(H>92){ analogWrite(humidity, 0); analogWrite(fae, 0); analogWrite(fan, 255); digitalWrite(blueLED, HIGH); digitalWrite(yellowLED, LOW); digitalWrite(whiteLED, LOW); } if(H==91){ analogWrite(humidity, 255); analogWrite(fae, 0); analogWrite(fan, 255); } if(H

  • @TheBoredRobotLLC

    @TheBoredRobotLLC

    8 ай бұрын

    The syntax for the "if" statements look good a first glance. First run some debug statements to see what conditions are being met. I would start with the "H" variable.