Error on uploading code

hey guys, I am not familiar with Arduino IDE. I am programing using the standard C library. I have all the library I need in the library folder. But when I try to compile the code it shows an error. Anyone know how to fix?

Posting pictures of code or errors is not much use.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Do you see that button at the right hand side in the orange bar in your screenshot? Please click it, it will copy the complete error to the clipboard. Next paste it in a reply.

Also, please post your code. In the IDE, use tools → auto format; next use edit → copy for forum which will pace the code in the clipboard (including needed code tags); next paste in a new (or the same) reply.

error message:
Arduino: 1.8.13 (Windows 10), Board: “Arduino Uno”

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:24:0,

             from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26,

             from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

             from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:233,

             from sketch\main.ino.cpp:1:

C:\Users\himyu\Desktop\main\main.ino:30:20: sorry, unimplemented: non-trivial designated initializers not supported

FILE uart_output = FDEV_SETUP_STREAM(uart_putch, NULL, _FDEV_SETUP_WRITE);

                ^

C:\Users\himyu\Desktop\main\main.ino:30:20: sorry, unimplemented: non-trivial designated initializers not supported

C:\Users\himyu\Desktop\main\main.ino:30:20: sorry, unimplemented: non-trivial designated initializers not supported

exit status 1

Error compiling for board Arduino Uno.

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

#define BAUD 9600

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// avr
#include <avr/io.h>
#include <util/delay.h>
#include <util/setbaud.h>
// graphics
#include <lcd.h>
#include <macros.h>
#include <ascii_font.h>
#include <graphics.h>
//sensors
#include "bh1750.h"
#include "dht11.h"
#include "hcsr04.h"

int uart_putch(char c, FILE *unused) {
  (void) unused;

  while (!(UCSR0A & (1 << UDRE0)));
  UDR0 = c;

  return 0;
}

FILE uart_output = FDEV_SETUP_STREAM(uart_putch, NULL, _FDEV_SETUP_WRITE);

void uart_init() {
  UBRR0H = UBRRH_VALUE;
  UBRR0L = UBRRL_VALUE;

  UCSR0A &= ~(1 << U2X0);
  UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
  UCSR0B = (1 << RXEN0) | (1 << TXEN0);

  stdout = &uart_output;
}

int main() {
  //start serial comms
  uart_init();
  //initialise LCD
  lcd_init(LCD_LOW_CONTRAST);
  clear_screen();
  show_screen();



  // setting up Distance env_sensor
  // ECHO on B4
  // TRIG on B5
  hcsr04 distance_sensor;
  hcsr04_setup(&distance_sensor, &PORTB, 5, &PORTB, 4);

  // Setting up Temperature and humidity sensor
  // Temprature sensor on B3
  //
  dht11 env_sensor;
  dht11_setup(&env_sensor, &PORTB, 3);

  //	Setting up light sensor
  // 	sensor SDA on PC4 (A4)
  // 	sensor SCL on PC5 (A5)
  bh1750_setup();

  while (1) {

    char src[20];
    char dest[20];
    clear_screen();


    /************************************************/
    // reading distance
    double distance;

    ////send values to UART
    if (hcsr04_read(&distance_sensor, &distance)) {
      printf("Distance read: %d mm\n", (int) (distance * 1000));
    } else {
      printf("Failed to read distance\n");
    }
    dtostrf((1000.0 * distance), 7, 3, src);
    strcpy(dest, "D=");
    strcat(dest, src);
    draw_string(0, 10, dest, FG_COLOUR);
    /************************************************/
    // reading Temperature and Humdity
    // please note Temperature cannot be read faster than
    // 1 reading per second
    int temperature;
    int humidity;
    // //send values to UART
    if (dht11_read(&env_sensor, &temperature, &humidity)) {
      printf("Temperature %d deg C, humidity %d%%RH\n", temperature, humidity);
    } else {
      printf("Failed to read temperature and humidity\n");
    }

    dtostrf(temperature, 7, 3, src);
    strcpy(dest, "T=");
    strcat(dest, src);
    draw_string(0, 20, dest, FG_COLOUR);

    dtostrf(humidity, 7, 3, src);
    strcpy(dest, "H=");
    strcat(dest, src);
    draw_string(0, 30, dest, FG_COLOUR);
    /************************************************/
    // reading Light sensor
    uint16_t light_level;

    //send values to UART
    if (bh1750_read(&light_level)) {
      printf("Light level = %u lux\n", light_level);
    } else {
      printf("Failed to read light level\n");
    }

    dtostrf(light_level, 7, 3, src);
    strcpy(dest, "L=");
    strcat(dest, src);
    draw_string(0, 40, dest, FG_COLOUR);


    show_screen();
    _delay_ms(2000);
  }



  return 0;
}

Hi,
Welcome to the forum.
The standard coding format for Arduino IDE C++
is


void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

What model Arduino are you writing code for?
Are your libraries suitable for Arduino C++.

I am surprised at the amount of code you have and now find out it doesn’t compile.
How about doing your code in stages and getting each stage working, before combining.
This way you will have less to debug as you know each stage worked.

Tom… :grinning: :+1: :coffee: :australia: