# Arduino and C programming

**URL:** <https://forum.arduino.cc/t/arduino-and-c-programming/1333819>\
**Category:** Programming\
**Created:** [December 19, 2024, 12:43pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819 "2024-12-19T12:43:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![98jijutsu](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/98jijutsu/32/1130492_2.png) [@98jijutsu](https://forum.arduino.cc/u/98jijutsu)\
**Post date:** [December 19, 2024, 12:43pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/1 "2024-12-19T12:43:07Z")

</div>

Hi I need some help here. What's the differences between the Arduino and C programming, in term of their purpose, programme structure, and code syntax? I just started learning Arduino code for blinking LED but how do I modify it to C programming? The LED turns on for 2400 ms and turns off for 1600 ms. I want to get some expert's opinion and not just ai.

---

<div class="post-metadata">

**Author:** ![pert](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/pert/32/217111_2.png) [@pert](https://forum.arduino.cc/u/pert)\
**Post date:** [December 19, 2024, 12:43pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/2 "2024-12-19T12:43:50Z")

</div>

I moved your topic to an appropriate forum category @98jijutsu .

In the future, please take some time to pick the [forum category](https://forum.arduino.cc/categories) that best suits the subject of your topic. There is an " **About the \_\_\_\_\_ category**" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in [the " **How to get the best out of this forum**" guide](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966). The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

---

<div class="post-metadata">

**Author:** ![zwieblum](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zwieblum/32/427702_2.png) [@zwieblum](https://forum.arduino.cc/u/zwieblum)\
**Post date:** [December 19, 2024, 12:54pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/3 "2024-12-19T12:54:03Z")

</div>

Is this some kind of homework assignment?

Anyway, did you check arduino website?

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [December 19, 2024, 12:57pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/4 "2024-12-19T12:57:41Z")

</div>

The Arduino IDE programming environment is C++ with extensions to allow the Arduino hardware to be controlled

---

<div class="post-metadata">

**Author:** ![MicroBahner](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/microbahner/32/238923_2.png) [@MicroBahner](https://forum.arduino.cc/u/MicroBahner)\
**Post date:** [December 19, 2024, 1:07pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/5 "2024-12-19T13:07:38Z")

</div>

> [@UKHeliBob](#):
>
> The Arduino IDE programming environment is C++ with extensions

... and a few limitations 😉 - depending on the target MCU.

---

<div class="post-metadata">

**Author:** ![98jijutsu](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/98jijutsu/32/1130492_2.png) [@98jijutsu](https://forum.arduino.cc/u/98jijutsu)\
**Post date:** [December 19, 2024, 1:13pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/6 "2024-12-19T13:13:34Z")

</div>

> [@98jijutsu](#):
>
> Hi I need some help here. What's the differences between the Arduino and C programming, in term of their purpose, programme structure, and code syntax? I just started learning Arduino code for blinking LED but how do I modify it to C programming? The LED turns on for 2400 ms and turns off for 1600 ms. I want to get some expert's opinion and not just ai.

Yeah, I already submitted it but I need some clarification. Yes, I've checked the website.

---

<div class="post-metadata">

**Author:** ![98jijutsu](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/98jijutsu/32/1130492_2.png) [@98jijutsu](https://forum.arduino.cc/u/98jijutsu)\
**Post date:** [December 19, 2024, 1:14pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/7 "2024-12-19T13:14:43Z")

</div>

So you mean the purpose of Arduino is to control a hardware?

---

<div class="post-metadata">

**Author:** ![98jijutsu](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/98jijutsu/32/1130492_2.png) [@98jijutsu](https://forum.arduino.cc/u/98jijutsu)\
**Post date:** [December 19, 2024, 1:15pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/8 "2024-12-19T13:15:13Z")

</div>

> [@98jijutsu](#):
>
> So you mean the purpose of Arduino is to control a hardware?

So you mean the purpose of Arduino is to control a hardware?

---

<div class="post-metadata">

**Author:** ![gcjr](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gcjr/32/314015_2.png) [@gcjr](https://forum.arduino.cc/u/gcjr)\
**Post date:** [December 19, 2024, 1:16pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/9 "2024-12-19T13:16:44Z")

</div>

> [@98jijutsu](#):
>
> I want to get some expert's opinion

you need to post the code ??

---

<div class="post-metadata">

**Author:** ![98jijutsu](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/98jijutsu/32/1130492_2.png) [@98jijutsu](https://forum.arduino.cc/u/98jijutsu)\
**Post date:** [December 19, 2024, 1:20pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/10 "2024-12-19T13:20:16Z")

</div>

Oh sorry I read it wrong lol

---

<div class="post-metadata">

**Author:** ![MicroBahner](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/microbahner/32/238923_2.png) [@MicroBahner](https://forum.arduino.cc/u/MicroBahner)\
**Post date:** [December 19, 2024, 1:27pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/11 "2024-12-19T13:27:56Z")

</div>

> [@98jijutsu](#):
>
> I just started learning Arduino code for blinking LED but how do I modify it to C programming?

What do you want to modify? Arduino sketches are written in C++ ( not pure C ). There are some hidden parts (e.g. main() ) to make it easier for beginners. You can write the main() function by yourself if you want to. But then you have to dig deeper into the Arduino core code. It does a lot of basic things for you - e.g. initializing the HW of the MCU - if you let it do its job.

---

<div class="post-metadata">

**Author:** ![DVDdoug](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/dvddoug/32/671533_2.png) [@DVDdoug](https://forum.arduino.cc/u/DVDdoug)\
**Post date:** [December 19, 2024, 3:45pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/12 "2024-12-19T15:45:22Z")

</div>

Most ANSI/ISO Standard C/C++ won't run on the Arduino (at least without modification) because C/C++ expects an operating system, file system, standard display, and standard keyboard. .i.e. The classic-standard "Hello World" won't work.

And, there's no way to read an I/O port or blink an LED with standard C/C++. Those hardware-specific things require special-additional libraries.

---

<div class="post-metadata">

**Author:** ![gcjr](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gcjr/32/314015_2.png) [@gcjr](https://forum.arduino.cc/u/gcjr)\
**Post date:** [December 19, 2024, 4:35pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/13 "2024-12-19T16:35:10Z")

</div>

> [@DVDdoug](#):
>
> Most ANSI/ISO Standard C/C++ won't run on the Arduino (at least without modification) because C/C++ expects an operating system

not true. i've developed lots of code on my laptop that runs fine on Arduino. The Arduino IDE use uses the industry standard GNU C++ compiler

of course, you can't execute code that actual drives a motor or controls other hardware on or connected to an Ardiuno on a laptop, by you can use prints to show what the arguments to such functions are.

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [December 19, 2024, 5:39pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/14 "2024-12-19T17:39:23Z")

</div>

This comes up every once in a while.

I think it is useful to differentiate between a language, and a language plus the context it is found in.

Many modern languages simply would not run on microprocessors, they are huge. In and of themsleves, I would say it would be like making the STL an actual part of the C++ language.

Modern language texts often start with a few chapters that are essentially all of C.

So Arduino is programmed in C++. Period. It is made easier by all the junk that comes out of the box with the IDE, and further so by the thousands of libraries for doing anything you might think of, almost.

Big rigs can be programmed in C or C++; usually there is a bunch of junk sitting around that doing so depends on.

For microprocessors that aren't as beefy as, say, the UNO, C has become a good fit with the modern compilers, and the heavies who thought it would never be so now have fewer things that actually need assembly language.

a7

---

<div class="post-metadata">

**Author:** ![xfpd](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/xfpd/32/1120236_2.png) [@xfpd](https://forum.arduino.cc/u/xfpd)\
**Post date:** [December 19, 2024, 6:25pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/15 "2024-12-19T18:25:57Z")

</div>

I am an expert at being a novice. At no time have I ever, knowingly, programmed in C++. It matters not to expert novices like me, that all the code I will ever write is supported by libraries using C++.

In the same vein, I do not speak German because I get "cranky," nor Italian because I order Pizza from the shop around the corner (ham and artichoke or spinach and garlic... venti minuti).

Knowing this little about the insides of programming languages has its benefit: I do not lose sleep when C/C++ wars start.

Program in C and learn to use the "mute" preference.

---

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [December 19, 2024, 8:03pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/16 "2024-12-19T20:03:10Z")

</div>

Mmm… pizza.

a7

---

<div class="post-metadata">

**Author:** ![jimLee](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jimlee/32/214865_2.png) [@jimLee](https://forum.arduino.cc/u/jimLee)\
**Post date:** [December 19, 2024, 8:09pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/17 "2024-12-19T20:09:54Z")

</div>

I always thought of C as the programming version of Latin. It the base for bloody near everything. c++ is kinda' like english. Closer to a modern language, Depends a lot on the accent/dialect you speak with. People are still futzing around with it.

-jim lee

---

<div class="post-metadata">

**Author:** ![zwieblum](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zwieblum/32/427702_2.png) [@zwieblum](https://forum.arduino.cc/u/zwieblum)\
**Post date:** [December 19, 2024, 8:58pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/18 "2024-12-19T20:58:40Z")

</div>

LISP. LISP is the classic greek of programming languages. Nobody ever heard of Latin. Or C. Or C++. Or PHP ...

 ![lisp-programmers](https://europe1.discourse-cdn.com/arduino/original/4X/a/c/0/ac093a6994cb0d9207f65cd9eef0279034f8dc6b.jpeg)

... now let the carnage begin ...

---

<div class="post-metadata">

**Author:** ![westfw](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/westfw/32/213443_2.png) [@westfw](https://forum.arduino.cc/u/westfw)\
**Post date:** [December 19, 2024, 9:39pm UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/19 "2024-12-19T21:39:45Z")

</div>

Arduino code for blink:

```arduino
void loop() {
  digitalWrite(LED_BUILTIN, HIGH); 
  delay(1000); 
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000); 
}

```

C code for blink (using avr-libc):

```arduino
int main() {
   while (1) {
     PORTB |= 1<<PINB5;
     _delay_ms(1000);
     PORTB &= ~(1<<PINB5);
     _delay_ms(1000);
   }
}

```

---

<div class="post-metadata">

**Author:** ![gcjr](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gcjr/32/314015_2.png) [@gcjr](https://forum.arduino.cc/u/gcjr)\
**Post date:** [December 20, 2024, 12:07am UTC](https://forum.arduino.cc/t/arduino-and-c-programming/1333819/20 "2024-12-20T00:07:37Z")

</div>

C is complete but no frills. It's been described as a high level assembler.

It was co-developed with Unix which was orignally written in assembler and C written to be able to access the hardware no other language was capable of doing.

C++ was originally implemented as a translator converting C++ into C. So C was capable of doing was C++ was capable of. Fortran was also originally implemented on Unix as a translator into C.

C++ has been described as having more "guard rails" than C

[Next page](https://forum.arduino.cc/t/arduino-and-c-programming/1333819.md?page=2)
