Instead of writing the code to the Arduino well see how to extract an existing code from the Arduino and save it in an hexadecimal format, which basically means ones and zeros. I will show you how the code is stored and burned to the Arduino and what software we need to extract it back, and then I also show you how to write back that extractor code to the Arduino sounds interesting, so lets get started. My new project was requiring some flexible pcbs and PCB way was the right solution for that and the other process is so simple: just go to and select flexible pcbs upload your Gerber files as always, and select your settings directly on their website. You also have the option for rigid Flex pcbs if you want and other settings for the color, the thickness, the gold immersion and so on. I received my pcbs in just a couple of days and they look amazing. The tracks are very small, but even so PCB way did a great job and they have capabilities that go even lower than that and you could check them on their website. So try yourself their services for flexible pcbs like mine and like that you can complete your awesome project and check more for other services for prototyping pcbs, automatic assembly, SMD stencil and much more on whats up. My friends welcome back. This here is an Arduino, obviously, but despite how we all call it, Arduino is not a microcontroller.

The Arduino is just the name of the development board, which is made out of the PCB the plastic pins. Also, some voltage Regulators, the connectors and everything that you see on this board, because the real microcontroller is this one here and in this case, is that Mega 228p and is made by a company that is called atmel or nowadays was acquired by microchip technology. So why am I telling you about this? Well, because I want you to understand how the code is uploaded to a microcontroller, and you have to understand that the microcontroller is not the entire board just this chip here and it could be any other chip. But basic arduinos are using that Mega chips and these have an AVR structure. You have to understand that inside such an AVR microcontroller, we have the main CPU. We have some flash memory e pro memory and SRAM, so we dont need any external memory for most applications. Almost all devices accept these small, tiny AVR chips, such as the 80, tiny, 85 and so on have a Serial interface, which can be used to connect larger CL, eeproms or Flash tubes. In case that you need more memory and these external memories come in the form of other chips like this one here, which has an icecristic Communication in this case. So AVR structure is using 32 registers of 8 Bits and the code that we upload to the Arduino. So the program instructions are stored in a non volve Time, flash memory.

Although the mcus are 8 bit, each instruction will take one or two 16 bits words. The size of the program memory is usually indicated in the naming of the device itself. For example, the atmega 64x has 64 kilobytes of Flash, while that Mega 32x, which is the one that the Arduino Uno is using, has 32 kilobytes. So for these microcontrollers we have no external program memory, and that means that all the code executed by the AVR core must be inside of the chip on its flash memory and thats the part we need to extract in this tutorial. Basically, inside of the Arduino, we have the program, memory, the data memory and the eprom, and we will focus on the program memory. This memory is separated into the boot flash section and the rest of the code, and we dont care about this boot section for now. So our code will be stored here. This, for example, is an Arduino code, but when this is programmed to the chip, it is not stored in a text. Format like this, the compiler is in charge of translating this text into zeros and ones and then to store those zeros and ones to the memory. For example, this is the binary data for This Blink code in hexadecimal format, and this is what we want to extract today. So that being said, lets see how to do it to be able to see the differences later in the video between what we upload and what we extract.

Ive prepared to Blink out, one blinks, each 100 milliseconds and the other one will blink each two seconds. I upload for now the 100 milliseconds to the Arduino Uno and, as you can see, the LED is blinking very fast, so now go ahead and download the software from below it is called AVR. Do this install it and run it to communicate with the Arduino? We cant use the USB connector. We need to create an ISP communication. These are the pins for an ISP communication on pins, 10, 11, 12 and 13.. So for this you could use an ISP programmer, but in case that you dont have one we can use another Arduino as a controller to make the difference. I will use a red Arduino for that, so this will be the master and this will be the Arduino from which we want to extract the code that we have uploaded before so first we get the master Arduino connected to your PC and run the Arduino IDE And here we go to file examples, Arduino ISP and we open this example code, select the Arduino Uno board, compile and upload this code to the master Arduino and just like that. We make it act as an ISP programmer. Now you have to make these connections for the master Arduino to the Arduino with a blink code, and these are the ISP communication pages and now get back to the AVR. Do the software for programmer obviously select Arduino, make sure that you have the master Arduino USB connected to your PC and in the com list, select the come of your master Arduino in my case.

Is this one and for the about rate I set it to 19200, but in your case it might be 115 200, because Ive seen some other models working at a different speed. Now, on the right side for the MCU select the atmega 228p, because the Arduino Uno is using that chip and now click detect and if the ISP connection between the master, Arduino and the code Arduino is good. You should get this message. Okay, so now, as you can see, we can access the flash memory where the code is the e pro memory and the fuses configuration lets go one by one, starting with the fuses, and these fuses are like switches and they could be 0 or 1 and they Basically, control the configuration of the microcontroller for the Arduino, we have the low fuse byte, the high fuse, byte extended and lb fuses. The low fuses will deal with the clock sources and each bit will control something, as you can see here, and the high fuse bits will control these parts, such as the reset, the Watchdog, the bootloader memory and so on. So if an Arduino code has changed these bits, you might also want to get these values as well when you get the entire code. So in the AVR software you click the read button next to the fuses Bits And Get These values, and there is no way of storing this. So you must write down these values, maybe open a notepad and paste those values there.

Okay, so now we have the fuses next lets read the code. You have to mark the recheck box for the flash memory and for the format you select. The Intel hex for hexadecimal now click the three dots and select where you want to save the code file, and I give it a name. For example, in my case, I name it blink 100 milliseconds dot X and I save it in this folder. So now that you have the file root, make sure that you have all the settings as I have and click go and the code is now extracted from the blue Arduino. The process is done. I go to that folder and, as you can see, I have the hexadecimal file of the code and these are just ones and zeros, but they contain the blink code. And now we do the same for the eprom memory Mark the read: checkbox click, the three dots and give it a name. I name it: eprom100, milliseconds, dot, Eep and now click the Go Button. So now the eprom data file is now extracted from the blue Arduino. So now we have the fuses The Flash data with the code and also the eprom, but why do we need the eprom? Well, because some codes might use the epro memory as well, for example, for my soldering iron project? I was turning the user settings on the eeprom, so if you want to copy the entire code, you might also want to extract the eprom memory, okay, so, finally, to demonstrate that the code that we have extracted works, I take the blue Arduino and using the Arduino Ide I upload this code with a blink of two seconds this time.

As you can see now, the LED is blinking a lot slower and now connect back the blue Arduino to the master Arduino with the ISP connections. We get back to the AVR software and make sure that you have these settings in the flash part we now select. The right option now select the hexadecimal file that we have extracted before from your PC folder. We also Mark the race, Flash and eprom checkbox. Now click go and the new code will be uploaded to the blue Arduino once finished, remove the reset wire or disconnect all the SP pins and reset the Arduino, and there you go. We now have the 100 milliseconds blink instead of the two seconds one. We have successfully extracted and programmed back the code from the Arduino okay, so back to the APR software. If you want to fully copy and upload a code, you must re upload all the parts so get the fuse values from your notepad file. You place them here in the software and also check the set uses. Checkbox then select the xlsmo file of the code and check the right checkbox. Then you also select the eprom file and also check the right checkbox. Make sure that all the settings are correct for the MCU type and the speed check also the erase Flash and eprom checkbox and click program. And now all the three parts are uploaded to the blue Arduino and just like that, you have copied the code from your Arduino and upload it back and have in mind that you only have access to the hexadecimal format of the code.

You wont be able to edit this code in the Arduino IDE, for example, you can only copy it and upload it again without editing the code, and you can do this with the Arduino Uno, an Arduino Nano or even a netmega 320 chip that is soldered to A prototyping board – all you need, is access to the ISP pins so guys. I hope that you have learned something new, if so, consider giving me a like or comment below thanks again and see you later guys, hey guys, so we are at the end of this video.