c++arduinohexgenerateavrdude

how can i generate hex file from cpp file with avrdude


I have a string code.

void setup() {

  pinMode(5, OUTPUT);
}


void loop() {
  digitalWrite(5, HIGH);
  delay(1000);
  digitalWrite(5, LOW);
  delay(1000);
}

I want to create a hex file from that string code using avrdude. Is there a command to do this? Thanks.


Solution

  • You're confusing some things here

    1. this is an Arduino sketch, not a .cpp file, you'll need the Arduino framework and most importantly a compiler to compile this

    2. avrdude is not a compiler so you cannot turn source code into binaries with it.

    3. AVRDUDE is a utility to download/upload/manipulate the ROM and EEPROM contents of AVR microcontrollers using the in-system programming technique (ISP).

    So you can use avrdude to upload the compiled program to your Arduino. Note that this only works if your Arduino model has a AVR microcontroller. It will not work for ARM, ESP or other stuff.