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 take a few moments to Learn and Use The Forum

Welcome to the Arduino Forum. This guide explains how to get the best out of this forum. Please read and follow the instructions below. Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is frustrating for you and frustrating for us.

It will help you get the best out of the forum in the future.

  • Your OS and version can be valuable information, please include it along with extra security you are using.

  • Always list the version of the IDE you are using and the board version if applicable.

  • Use quote or add error messages as an attachment NOT a picture.

  • How to insert an image into your post. ( Thanks @sterretje )

  • Add your sketch where applicable but please use CODE TAGS ( </> )

  • Add a SCHEMATIC were needed even if it is hand drawn

  • Add working links to any specific hardware as needed (NOT links to similar items)

  • Remember that the people trying to help cannot see your problem so give as much information as you can


  • Ensure you have FULLY inserted the USB cables.

  • Check you have a COMMON GROUND where required. ( Thanks @Perry)

  • Where possible use USB 2.0 ports or a USB 2.0 POWERED HUB to rule out USB 3.0 issues.

  • Try other computers where possible.

  • Try other USB leads where possible.

  • You may not have the correct driver installed. CH340/341 or CP2102 or FT232 VCP Drivers - FTDI

  • There may be a problem with the board check or remove your wiring first.

  • Remove any items connected to pins 0 and 1.


  • Close any other serial programs before opening the IDE.

  • Ensure you turn off any additional security / antivirus just to test.

  • There may be a problem with the PC try RESTARTING it.

  • You may be selecting the wrong COM port.

  • Avoid cloud/network based installations where possible OR ensure your Network/Cloud software is RUNNING.

  • Clear your browsers CACHE.

  • Close the IDE before using any other serial programs.

  • Preferably install IDE’s as ADMINISTRATOR or your OS equivalent


  • CH340/341 based clones do not report useful information to the “get board info” button.

  • NANO (Old Types) some require you to use the OLD BOOTLOADER option.

  • NANO (ALL Types) See the specific sections lower in the forum.

  • NANO (NEW Types) Install your board CORE’s.

  • Unless using EXTERNAL PROGRAMMERS please leave the IDE selection at default “AVRISP mkII”.

  • Boards using a MICRO usb connector need a cable that is both DATA and CHARGE. Many are CHARGE ONLY.

CREATE editor install locations.

  • On macOs ~/Applications/ArduinoCreateAgent-1.1/

  • On Linux ~/ArduinoCreateAgent-1.1/config.ini

  • On Windows C:\Users[your user]\AppData\Roaming\ArduinoCreateAgent-1.1

Performing the above actions may help resolve your problem without further help.

Language problem ?

Try a language closer to your native language:

Thanks to all those who helped and added to this list.

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>
#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() {

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

  stdout = &uart_output;

int main() {
  //start serial comms
  //initialise LCD

  // 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)

  while (1) {

    char src[20];
    char dest[20];

    // 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);


  return 0;

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

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:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.