Connect with us

Problems with code

Discussion in 'Microcontrollers, Programming and IoT' started by electronicsquestions2234, Dec 27, 2017.

  1. electronicsquestions2234

    electronicsquestions2234

    8
    0
    Dec 22, 2017
    Hi, people. So, I was wondering about some problems with my code and how I fix them. I am simply setting up a DHT11 with an LCD and arduino UNO. Thanks, and here is my code:

    #include <DHT.h>
    #include <DHT_U.h>

    #include <LiquidCrystal.h>


    int SENSOR = 2;

    int VO = 3;
    int RS = 4;
    int E = 5;
    int D4 = 6;
    int D5 = 7;
    int D6 = 8;
    int D7 = 9;

    int temp;
    int humidity;

    DHT dht (SENSOR, DHT11);
    LiquidCrystal lcd (RS, E, D4, D5, D6, D7);

    void setup() {
    dht.begin();

    lcd.begin(16, 2);
    analogWrite(VO, 50); //contrast
    }

    void loop() {
    humidity = dht.readHumidity();
    temp = dht.readTemperature();

    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Temperature: ")
    lcd.print(temp);
    lcd.print ("C")
    lcd.setCursor(0,1);
    lcd.print("Humidity: ")
    lcd.print(humidity);
    lcd.print(%);

    delay(15000);



    }
     
  2. electronicsquestions2234

    electronicsquestions2234

    8
    0
    Dec 22, 2017
    The error says " Error compiling for Arduino/Genuino Uno."
     
  3. electronicsquestions2234

    electronicsquestions2234

    8
    0
    Dec 22, 2017
    here is the entire error code: (warning: verbose output enabled)

    Arduino: 1.8.5 (Windows 8.1), Board: "Arduino/Genuino Uno"

    C:\Users\Family\Desktop\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Users\Family\Desktop\Arduino\hardware -tools C:\Users\Family\Desktop\Arduino\tools-builder -tools C:\Users\Family\Desktop\Arduino\hardware\tools\avr -built-in-libraries C:\Users\Family\Desktop\Arduino\libraries -libraries C:\Users\Family\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=0X2341_0X0043 -ide-version=10805 -build-path C:\Users\Family\AppData\Local\Temp\arduino_build_528632 -warnings=none -build-cache C:\Users\Family\AppData\Local\Temp\arduino_cache_17742 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\Family\Desktop\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Users\Family\Desktop\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Users\Family\Desktop\Arduino\hardware\tools\avr -verbose C:\Users\Family\Documents\Arduino\Tempandhumiditylcd\Tempandhumiditylcd.ino
    C:\Users\Family\Desktop\Arduino\arduino-builder -compile -logger=machine -hardware C:\Users\Family\Desktop\Arduino\hardware -tools C:\Users\Family\Desktop\Arduino\tools-builder -tools C:\Users\Family\Desktop\Arduino\hardware\tools\avr -built-in-libraries C:\Users\Family\Desktop\Arduino\libraries -libraries C:\Users\Family\Documents\Arduino\libraries -fqbn=arduino:avr:uno -vid-pid=0X2341_0X0043 -ide-version=10805 -build-path C:\Users\Family\AppData\Local\Temp\arduino_build_528632 -warnings=none -build-cache C:\Users\Family\AppData\Local\Temp\arduino_cache_17742 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Users\Family\Desktop\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Users\Family\Desktop\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Users\Family\Desktop\Arduino\hardware\tools\avr -verbose C:\Users\Family\Documents\Arduino\Tempandhumiditylcd\Tempandhumiditylcd.ino
    Using board 'uno' from platform in folder: C:\Users\Family\Desktop\Arduino\hardware\arduino\avr
    Using core 'arduino' from platform in folder: C:\Users\Family\Desktop\Arduino\hardware\arduino\avr
    Detecting libraries used...
    "C:\Users\Family\Desktop\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\Family\Desktop\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Users\Family\Desktop\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\Family\AppData\Local\Temp\arduino_build_528632\sketch\Tempandhumiditylcd.ino.cpp" -o "nul"
    "C:\Users\Family\Desktop\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\Family\Desktop\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Users\Family\Desktop\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Family\Documents\Arduino\libraries\DHT_sensor_library" "C:\Users\Family\AppData\Local\Temp\arduino_build_528632\sketch\Tempandhumiditylcd.ino.cpp" -o "nul"
    "C:\Users\Family\Desktop\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\Users\Family\Desktop\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Users\Family\Desktop\Arduino\hardware\arduino\avr\variants\standard" "-IC:\Users\Family\Documents\Arduino\libraries\DHT_sensor_library" "C:\Users\Family\AppData\Local\Temp\arduino_build_528632\sketch\Tempandhumiditylcd.ino.cpp" -o "C:\Users\Family\AppData\Local\Temp\arduino_build_528632\preproc\ctags_target_for_gcc_minus_e.cpp"
    In file included from C:\Users\Family\Documents\Arduino\Tempandhumiditylcd\Tempandhumiditylcd.ino:2:0:

    C:\Users\Family\Documents\Arduino\libraries\DHT_sensor_library/DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory

    #include <Adafruit_Sensor.h>

    ^

    compilation terminated.

    Using library DHT_sensor_library at version 1.3.0 in folder: C:\Users\Family\Documents\Arduino\libraries\DHT_sensor_library
    exit status 1
    Error compiling for board Arduino/Genuino Uno.
     
  4. electronicsquestions2234

    electronicsquestions2234

    8
    0
    Dec 22, 2017
    The important part is this;
     
  5. electronicsquestions2234

    electronicsquestions2234

    8
    0
    Dec 22, 2017
    I think.
     
  6. Harald Kapp

    Harald Kapp Moderator Moderator

    9,137
    1,846
    Nov 17, 2011
    Sounds obvious.
    Check with the windows explorer whether this directory /folder) and file exist.They may exist in another location, in that ase a copy to the expected location should suffice. Otherwise you'll have to download the library, e.g. here.
     
  7. Bluejets

    Bluejets

    3,444
    698
    Oct 5, 2014
    In the loop, lines 5 and 9 have incorrect syntax. .... ("Temperature ....and ..... ("Humidity ... I'll leave you to work out the rest.
     
  8. Harald Kapp

    Harald Kapp Moderator Moderator

    9,137
    1,846
    Nov 17, 2011
    Well spotted.
    Looks like there is more than one faulty spot here.
     
  9. electronicsquestions2234

    electronicsquestions2234

    8
    0
    Dec 22, 2017
    thx.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-