As noted in Majenko's answer, the Arduino IDE doesn't provide a breakpoint mechanism but Atmel Studio does support breakpoints.[*]
However, if you have a switch and an LED, you can track the progress of your program in a way that provides some of the benefits of breakpoints. You would add a subroutine, say BPReport(), that via serial output or an LCD ...
Can we read and get C codes from compiled codes from Arduino hardwares?
While it is possible, even trivial, to disassemble machine code, it is very difficult to convert the assembly code into a higher-level language, and essentially impossible to turn it back into an exact copy of the source code it came from. There simply isn't enough information in the ...
One approach is to look at the assembly listing of the program.
After compiling the program (via the Verify or Download button) locate the directory where the .cpp, .hex, and .elf files for the program have been stored. (If you have trouble finding them, briefly turn on verbose compile options in the arduino IDE and look at the directory names in the ...
The ATmegaXX8 does not support JTAG, but the ATmegaXX0, 'XX1, and 'XX4 do. The 'XX8 (as well as other AVR families) supports debugWIRE, which allows debugging over ISP. You will need one of Atmel's debuggers such as the AVR ONE! or the Atmel-ICE as well as Atmel Studio in order to use it.
int laastButtons; // save the previous deBounce read.
for(int x; x<4; x++)
laastButtons[x] = lastButtons[x];
Well, there's a common bug right away. An array with three slices, numbered 0, 1 and 2, and you're accessing them with a loop that counts from 0 to 3.
Spot the error.
Also, in the for loop, what number does it start counting from?
The Arduino Uno uses the Atmel Atmega328p microcontroller, which only has one debug option, DebugWire. There are a few tools that can work with it, but the least expensive and most commonly available is the AVR Dragon.
You can use AVR Studio 6 for this. You can use the .elf file file produced during the Arduino build process directly, but setting up the ...
Casting a number to a char* doesn't convert the number to a string. Instead it converts the number to a pointer and starts reading chars from that location.
Either pass the number to a String constructor, or pass it through ltoa().
ltoa(..., ss, 10);
Also, don't forget to allocate memory for finalss and NUL-...
Assuming you have enough time and money to spend on this project. ($50 is a bargain for a debugger, believe me. About a decade ago I wrote an assembler/debugger suite for a very small niche market microcontroller, the Maxim Integrated MAX1464, using a combination of SciTe and Perl/Tk. Writing your own debugger is a great educational project, if you have the ...
As somebody else suggested, 9V batteries are pretty weak. They only provide a very small number of mAh (milliamp/hours) before their voltage starts to drop. Once the voltage drops to around 7 volts, the regulator in the Arduino can't keep providing 5 volts, so your Arduino resets.
Wire up 6 AA batteries in series. That will provide a much "stiffer" 9 volt ...
Though Majenko his answer is correct there are some other options.
As to the real hardware debugging as stated by majenko I would say:
Install and use a real IDE, such as Atmel Studio or the arduino eclipse plugin called sloeber (I'm author), and
Use a full hardware debugger or hardware that has it on board like the Arduio zero or hardware using other ...
The Arduino-Debug library provides a simple on-target debugger for Arduino sketches. Debug command are added directly to the sketch. A debugger command shell is started on break-points and assertions.
The screen-shot above shows the example sketch run on an Arduino Mega with Serial output monitor used by application and Serial1 used for the debugger shell. ...
The Servo library uses Timer 1 to create the servo control signal. That means it can run the servo on any pin or combination of pins, and at the 50Hz speed that a servo likes best.
However, pins 9 and 10 also use Timer 1 to create the PWM signal.
It can't do both.
As soon as you start using the Servo library you lose PWM on pins 9 and 10.
So what can you ...
For convenience, here is a comment: You wrote, “I've tried the code above but it didn't work”. That is inadequate to convey what happened and what you wanted to happen. Please edit your question to include a clear statement of symptoms and desired results.
Now on to an answer.
From “I'm only using 2 readers to find the correct and make it work”, I ...
It would probably help if you were using the right pin. In the pins_arduino.h file for the Uno is this diagram:
// PC6 1| |28 PC5 (AI 5)
// (D 0) PD0 2| |27 PC4 (AI 4)
// (D 1) PD1 3| |26 PC3 (AI 3)
// (D 2) PD2 4| |25 PC2 (AI 2)
// PWM+ (D 3) PD3 5| |24 PC1 (AI 1)
// (D 4) ...
The Due (more specifically the SAM3X) uses its own proprietary protocol. It's all embedded in the bootloader, which is hard wired in the ROM and can never be changed (idiotic if you ask me).
I know of two systems for communicating with it. Atmel's SAM-BA program, and the open source BOSSA. The command line version of BOSSA (bossac) is used by the Arduino ...
Not in the Arduino IDE.
You need to:
Install and use a real IDE, such as Atmel Studio, and
Use a full hardware debugger
There is no provision for debugging through the UART/USB interface using the bootloader.
You seem to have been programming in Java recently, because many of your errors have a Java ‘whiff’ to them. This, as you’ve tagged, is C++, not Java.
a. You wrote leftPressed == true. This is much more simply expressed by the expression leftPressed.
b. You wrote middlePressed == false. This is much more simply expressed using the “not” ...
Without very specialized software that can create two new devices with the correct "teeing" policy, it's not going to be possible. Only one program can open a serial port at a time (certainly and have it get anything intelligible out of it...)
I would suggest you may want to add a second serial port. Use an FT232 adaptor to communicate on another serial ...
You read the button once, in setup(). The function is not called every time the variable's value is read, only when the line is executed and the variable assigned to. Move the digitalRead() call and assignment into loop(), before you check the variable's value.
I finally found it: Problem was solved after commenting those three lines in */Arduino-like IDE/app/uploader.py:
pre_serial_port = serial_port
wait_for_upload_port = self.args.get('upload.wait_for_upload_port', 'true') == 'true'
serial_port = resetSerial(pre_serial_port, self.output_console, wait_for_upload_port)
# if self....
Aaaaah, ok, now I see...
+5V - Reed - LED - input pin - 1k resistor - ground
If so the problem is that a red led has (usually) a voltage drop of about 1.5V, while the green one has a voltage drop of 1.8V-2.0V. The Atmega 328P has a Vih (i.e. the minimum voltage needed for a reliable high) of 0.6*Vcc, so for a 5V supply this value is 3V.
You could get your program to output messages to the serial pin on your board, Tx. For example:
Serial.begin(9600) //baud rate of 9600
You can use this to print out string and integers. Here is the link to further information on the Arduino website - https://www.arduino.cc/en/reference/serial
If you are already using the ...
I had this problem when working with Arduino IDE and XOD running on top of it.
What I found; looked like baud rates were being set differently at different stages in the setup. I compared Windows 'device settings', arduino IDE settings and XOD settings...and they are not the same and seem to change ? ...hence the 'avrdude:stk500_**** errors!
There are two major flaws with your program - and both of them can be "fixed" by you understanding some concepts better.
Firstly, in your program, there is no concept of "When the button is pressed", only "While the button is pressed". This is caused by an error in your understanding of how reading of buttons needs to be done.
The digitalRead() function ...
There is provision in the USBasp specification for a UART connection, however, not all manufacturers copy the original schematic exactly, and no firmware actually contains the appropriate code for CDC/ACM required in order to enable it. And even if they did, technically low-speed CDC/ACM is a violation of the USB protocol and not all operating systems will ...
You haven't posted any code, so any answer is guesswork. However ... if your code makes decisions based on external events (eg. readings from sensors) then it may allocate memory differently, and in a different order, each time.
Sometimes memory allocation leaves gaps (known as "heap fragmentation"). Small differences in your results probably show slightly ...