How can i run C code in Arduino ?

Discussion in 'Embedded Systems and Microcontrollers' started by ValarVictorius, Feb 26, 2016.

  1. ValarVictorius

    Thread Starter New Member

    Nov 17, 2015
    15
    0
    I want to run my C code in Arduino. But i don't want convert C to Arduino. What can i do ?
     
  2. mcgyvr

    AAC Fanatic!

    Oct 15, 2009
    4,771
    971
    Can you be a bit more specific?
    Are you just saying you want to write code in C and not use the Arduino IDE?

    Or are you wanting to write programs and not have to use the setup and void loops?
     
  3. Papabravo

    Expert

    Feb 24, 2006
    10,163
    1,796
    Get a c compiler for the ATMega328 and ditch the Arduino environment with a bit of bare metal programming.
     
  4. sirch2

    Well-Known Member

    Jan 21, 2013
    1,008
    351
    Arduino IDE programs are written in C
     
  5. alfacliff

    Well-Known Member

    Dec 13, 2013
    2,449
    428
    the arduino does not have the memory to hold a run time c program. the probrams are compiled so they actually run in machine language of 1's and 0's which takes much less memory.c is like basic and other languages, made readable to humans, but very seldom to processors.
     
  6. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,397
    497
    You can not because Arduino can not.

    Arduino language is C like, but IT IS NOT C.
    Either rewrite your C code or find someone to rewrite it for you.
     
  7. DickCappels

    Moderator

    Aug 21, 2008
    2,662
    633
    absf likes this.
  8. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,397
    497
    People, people, people...

    The problem is not the microcontroller. Yes, it is ATMega 328 with a bootloader.

    The problem is the ability to load code into the ATMega 328. That is why the dude is using Arduino board and Arduino environment. But since both parts are Arduino, it needs to be in Arduino language. Which the dude is not willing (yet) to invest any time into. So the dude has two choices:
    1) rewrite the code
    2) buy/build/steal hardware to load code into ATMega 328, buy/steal ATMega 328 chip or chips. But that just the microcontroller chip, you still need the rest of the circuit that goes around the microcontroller, like: clock crystal, capacitors, resistors, RS232 chip, etc., it is eFFING easier to just buy Arduino board and rewrite the C code.
     
  9. dannyf

    Well-Known Member

    Sep 13, 2015
    1,828
    365
    What's that ("Arduino language")?
     
  10. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,397
    497
    What Arduino says they are using. It is similar to C, but it is NOT C.
     
  11. dannyf

    Well-Known Member

    Sep 13, 2015
    1,828
    365
    really?
     
  12. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,397
    497
    From the website: https://www.arduino.cc/en/Guide/Introduction

    "To do so you use the Arduino programming language (based on Wiring), and the Arduino Software (IDE), based on Processing."
    Wiring: http://wiring.org.co/
    Processing: https://processing.org/

    "and people wanting to understand the technical details can make the leap from Arduino to the AVR C programming language on which it's based. Similarly, you can add AVR-C code directly into your Arduino programs if you want to."


    Well. I did find how to load C into Arduino Uno: https://balau82.wordpress.com/2011/03/29/programming-arduino-uno-in-pure-c/ So I guess OP's problem is solved.
     
  13. dannyf

    Well-Known Member

    Sep 13, 2015
    1,828
    365
    Under the hood, the Arduino compiler is GCC.

    So you think GCC can compile something that's not C/CPP?

    Forget about what others say to you - they can say whatever they want. End of the day, you should be able to think critically.
     
  14. DickCappels

    Moderator

    Aug 21, 2008
    2,662
    633
    Yes, to program an AVR controller without the bootloader you need an inexpensive programmer. Software for the programmers are free and widely available.
     
  15. dannyf

    Well-Known Member

    Sep 13, 2015
    1,828
    365
    The simplest would be to write your C code in the arduino ide and compile it and upload it to your arduino.

    Nothing else is needed.
     
Loading...