c# / c++ to hex please please help  

hi
i have been searching all day to try and find how to go from a .c file to a hex so i can program in strait c# / c++

i have got avr dude workin for me but am lost on .hex

also where can i find the actual c# code for things like delay() millis() and serial.print ect ect

thanks guys ur awsome

callum

C# ??? There is no C# here, only C and C++ (and some asm). :smiley:

Basically, you're looking for a way to go from source code to binary ? Then you need a compiler (some compilers in fact), maybe an assembler, a linker and the object dumper. All this you'll find in the GNU AVR-GCC toolchain. Many docs and how-to lies around on how to program the Arduino without the Arduino environnement. You could give a look to the Arduino on Eclipse tutorial Arduino Playground - Eclipse

Every source code is in the arduino Library, located at /hardware/cores/arduino on your Arduino installation directory.

No offence here, but having read your last posts, it looks like you're quite a beginner. You should really not borrow yourself with complex developement tools until you've got to the limits of the Arduino environnement... which are not really to reach. AVR programming is tricky and complicated and may result in sleepless nights and coffee abuse, even for experienced developers :slight_smile:

thankyou very much

yeah i know im getting to far ahead but im waiting on parts for the next coupple of weeks and need something to do in the meantime so i thaught hay ill learn strait c/c++

oh and my bad i presumed c# was c hehe

thanks anyway man appreciate it

Please note that the difference between the so-called "Arduino language" and C/C++ is extremely superficial. Arduino is basically C++ without the need to declare your functions and no explicit main() function.

A little example :

Arduino :

void setup() {
    pinMode(4, OUTPUT);
    }

void loop()
    digitalWrite(4, HIGH);
    delay(500);
    digitalWrite(4, LOW);
    delay(500);
    }

C++, (almost) as produced by the Arduino preprocessor (In fact, this is C, but any C code is theorically a valid C++ code) :

#include "WProgram.h"

void setup();
void loop();

int main(void) {
    setup();
    for (;;) { loop(); }
    }

void setup() {
    pinMode(4, OUTPUT);
    }

void loop()
    digitalWrite(4, HIGH);
    delay(500);
    digitalWrite(4, LOW);
    delay(500);
    }

(btw, why "man" ? I don't remember having given any gender-related information, and not any geek is a man, you know ? :o)

sorry iv come to presume :-[

and i know arduino has it end up like that but im also wanting to learn so i dont have to use the about 2kb that arduino needs total to run

the bottom line

i have nothing to do really for the next 2-3 weeks thaught this mite entertain me

thanks friend?

callum

and i know arduino has it end up like that but im also wanting to learn so i dont have to use the about 2kb that arduino needs total to run

The 2kb bootloader is not related to the Arduino language but to the program upload process. You can avoid it with using an ICSP programmer, like AVRISPMkII (search the forums about this) But don't worry, a 14kb space is quite enough for most projects. When you'll get more experienced with the Arduino, you can maybe considerer burning your own µCs and making your own PCB...

The library takes also a few kbs, but writing code without using it may be a painful process, and is most related to assembly language than C/C++. Be warned ^^

May I suggest not trying to learn everything at the same time ? Going slowly and making things to work before going on to something else is a more rewarding way to work and evolve in your knowledge of physical computing.

Anyway if you want to learn C++, go ahead :slight_smile: This is still a great language and will open you the way to most modern languages.

"C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off". Bjarne Stroustrup, "inventor" of C++

(btw, why "man" ? I don't remember having given any gender-related information, and not any geek is a man, you know ? :o)

So that's not you in your avatar? I guess that coupled with interpreting your username as leet-speak for "the boy" gave me the impression that you were a guy. Also, both hobby and professional engineers tend to overwhelmingly be men, so you got that whole "statistically male" thing going there.

  • Ben

haha nice quote

and cheers for that

one ov the things im waiting on is a cheap serial isp programmer that i have 2 use with ponyprong

i will probabily buy a avrisp programmer later to

im also waiting on a coupple of trancievers so obveaslly ned two boards to deal with it and i dont have to diecimila's to play with so ill be using a atmega168 standalone on breadboard

thanks

callum

So that's not you in your avatar? I guess that coupled with interpreting your username as leet-speak for "the boy" gave me the impression that you were a guy. Also, both hobby and professional engineers tend to overwhelmingly be men, so you got that whole "statistically male" thing going there.

It's basically because I don't really like the "statistically male" thing that I prefer not to be referred to as a gender... I appreciate your analysis, but I think most people, in contexts such as this forum, will refer to you as a guy just because you seem to be into technical stuff... and I'm not at ease with this.

But it is not really offensive anyway, just a bit annoying... but much less than an hard-to-kill mosquito :slight_smile:

Didn't know "tehboii" (originally spelled teh boï) was so explicitely related to "the boy" (even if it indeed comes from that, due to an ex boyfriend's style of writing)... English is not my mother language, as you've probably already guessed :slight_smile:

I appreciate your analysis, but I think most people, in contexts such as this forum, will refer to you as a guy just because you seem to be into technical stuff... and I'm not at ease with this.

I guess for me gender isn't such a big deal. I don't really care so much if the person I'm talking with is a guy or a girl, and I don't think it would bother me if someone if someone on a forum addressed me as a woman. But I understand that others feel differently about these things and I can respect that difference of opinion.

English is not my mother language, as you've probably already guessed :slight_smile:

I only know this from the content you have posted so far. I'd never be able to tell from your English, though. It's better than a lot of the writing I see from people for whom English is their first language.

Ok, enough thread-hijacking from me. Sorry about the interruption!

  • Ben

But I understand that others feel differently about these things and I can respect that difference of opinion.

:slight_smile: Just to clear a few things up : I'm not pretending to be a girl, I was just answering to an unverifiable assumption :slight_smile:

I only know this from the content you have posted so far. I'd never be able to tell from your English, though. It's better than a lot of the writing I see from people for whom English is their first language.

whow, thanks :-[

Ok, enough thread-hijacking from me. Sorry about the interruption!

Let's go back to Arduino.net in C# :smiley:

ok

i played around with trying to get arduino going on eclipse but it hates me and wont spit out a .hex

i need a .hex so i can load it with (shudder) ponyprong when i use a standalone microcontroller

is there at least a way i can get a .hex from arduino? i dont really want to have to buy a avrisp mk2 just yet as im trying to save.

thankyou!

callum

When you compile a sketch in the Arduino IDE, the hex file appears in the applet subdirectory of your sketch's directory. On Windows the path would be

My Documents/Arduino/MySketch/applet/MySketch.hex

You can then load that hex file onto your controller's mega168 with an ICSP using something like AVR Studio or avrdude.

  • Ben

thankyou ben! forgot to look there (need the head hitting smiley)