Questions tagged [c]

C is a procedural programming language which is widely used in embedded systems. PLEASE NOTE: Arduino is typically programmed in C++, not C.

The C programming language is the (direct or indirect) predecessor of many modern programming languages, although it is still actively used and developed. It is very similar to C++, except that C is not object oriented. That is, it will only support simple data structures which have no member functions.

Note: Arduino is usually programmed in C++, not C.

Please do not use this tag to indicate a general programming question. You may want to consider using the tag instead.

431 questions
19
votes
5 answers

deprecated conversion from string constant to 'char*'

What does this error means? I can't solve it in any way. warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
Facorazza
  • 439
  • 2
  • 6
  • 17
17
votes
1 answer

How do I convert a float into char*?

Asked this question on Electrical Engineering Stack Exchange and was directed here: Pretty self explanatory; how would I go about converting a float into a char*? I have code in which the float 'resistance' is constantly being updated. I would like…
higgsboson
  • 173
  • 2
  • 2
  • 6
16
votes
6 answers

Arduino: How to get the board type in code

I want to write a sketch that can be compiled on different Arduino boards. I want to display on the PC which board is currently connected. This means that the user connects the PC via USB cable to the Arduino/Teensy board in which runs my sketch and…
Elmue
  • 481
  • 1
  • 3
  • 10
12
votes
6 answers

Using String instead of C string, yet another attempt to touch a loaded issue

I've been reading a lot over the years why we should not use the notorious String class and how heap fragmentation is bad practice and not professional and we should never use it in our programs or we'll never enter the C hall of fame and get to be…
Nino
  • 411
  • 4
  • 9
12
votes
3 answers

Writing C Program outside of Arduino IDE?

I like the idea of using the Arduino IDE for simple projects and for getting started with Arduino, but the consensus I've gotten so far is that it is for those who are new to Arduino and/or programming in general. My understanding is that it is…
smeeb
  • 509
  • 2
  • 10
  • 21
11
votes
3 answers

How to call C functions from Arduino sketch?

I would like to know if there is a way to call functions that are contained within C files using an Arduino sketch? My C file declares and defines a function. To save putting the messy function definition into my Arduino sketch, I'd like to call…
user_name
  • 317
  • 1
  • 3
  • 11
11
votes
4 answers

SAM3X8E (Arduino Due) Pin IO registers

How do the IO registers of Arduino Due work? On Arduino Uno just set DDRx, then PINx to read, PORTx to write, I'd like to do the same thing with an Arduino Due, but it has many more registers, such as PIO_OWER, PIO_OSER, PIO_CODR, PIO_SODR, etc. I…
Alex
  • 315
  • 2
  • 3
  • 9
10
votes
3 answers

How can I program an arduino in pure C/C++?

I am a beginner and I want to learn AVR C/C++. Can I do this using an Arduino? (I'm asking this because I already have one). If so, could someone tell me using which IDE can I write code in pure C/C++ and then flash it to the Atmega328P on the…
ICRed
  • 101
  • 1
  • 1
  • 3
9
votes
2 answers

Arduino interruption (on pin change)

I use the interrupt function to fill an array with values received from digitalRead(). void setup() { Serial.begin(115200); attachInterrupt(0, test_func, CHANGE); } void test_func() { if (digitalRead(pin) == HIGH) { …
user277820
  • 91
  • 1
  • 4
8
votes
6 answers

how fast does loop() run in Arduino

Hi I am using Arduino Nano to gamify my experience on Unity3D. I know that Update() in Unity3D runs every frame per second but I because I'm not an electronics guy I don't know how loop() function runs on Arduino. Does it depends on number of CPU…
8
votes
2 answers

Basic makefile for avr-gcc

I would like to make a makefile for compiling c programs for the arduino. I am somewhat familiar with make but have never used it with avr-gcc. What is the simplest way I could put the commands below in a makefile? $ avr-gcc -Os -DF_CPU=16000000UL…
connorwstein
  • 183
  • 1
  • 1
  • 4
7
votes
3 answers

How do I extract code from an arduino?

I updated and uploaded some code on another computer that got wiped and didn't send the new code to my current computer, the updated code is still on the board but I don't have access to it. How do I get it back?
Awesome_Ace22
  • 87
  • 1
  • 1
  • 2
7
votes
4 answers

ATtiny85 minimum setup to blink led

What would be the (very) minimum schematic to make a ATtiny85 blink a led? Restrictions are: There must be a C program compiled and uploaded to it, just like an Arduino board would have. The code would use a simple "delay" to wait a little bit…
DrBeco
  • 269
  • 1
  • 2
  • 8
7
votes
3 answers

"EVERY_N_MILLISECONDS"

One of the FastLED examples that I've seen was using code that looks like this: EVERY_N_MILLISECONDS( 300 ) { transition_step(); } I've copied it and successfully used it in the same context - but I have no idea what it is or how it works. A…
Lefty
  • 347
  • 2
  • 4
  • 12
6
votes
2 answers

Problem importing a library in .h file

I have following code: MyApp.ino: #include "DfRobotLcdShield.h" void setup() { } void loop() { } DfRobotLcdShield.h: #include When I try to compile, I'm getting the error: In file included from…
Thomas S.
  • 566
  • 3
  • 8
  • 21
1
2 3
28 29