Learn what to do if your sketch uploads but the board is unresponsive or does not produce expected behavior.
1. Check your code
Even if your sketch compiles successfully, runtime errors can occur when code is being executed on the board. This error will not stop the code from executing but may result in unexpected behavior.
An example of this are handling of arrays:
int array; int value = array; array[-100] = 10;
In the above example,
value we will be assigned an indeterminate value from memory outside the array. On the other hand,
array[-100] = 10 will overwrite memory outside the array, which may interfere with other parts of your code.
Try this to check for and avoid runtime errors:
- Try uploading a simple example from the IDE. If it works, the problem may be due to a runtime error.
- Take care to not assign values or read from outside the range of a declared array.
- Debug the code by inserting
Serial.print()calls and checking the Serial Monitor. Use this method to check what values get assigned to important variables and when the code branches, e.g. on an
if()statement. Consider using the ArduinoTrace to make this process simpler.
2. Check the power supply
An external power source needs to be stable and to have sufficient current and voltage to power your setup.
- Check the requirements for your devices on Arduino Docs.
- Try powering the setup from your computer via USB.
- Try a different USB cable to rule out damage to the cable.
3. Check board connections and components
- Make sure that the components connected to the board are working properly and there are no short circuits.
- Try connecting one component at a time and try running the sketch after each added component.