Freeze during program writing

I am controlling two 2-way solenoids with an arduino mega (atmega 2560). one solenoid controls positive pressure, the other opens negative pressure. I have the solenoids programmed thru spi and have timing implemented to alternate between positive and negative pressure. When I make an adjustment to the code and upload it to the arduino it freezes in whatever state it is in. This results in either the positive or negative being left open longer than anticipated and over pressurizes. anyway to eliminate this freeze when uploading code?

Proportional_feedback.ino (2.58 KB)

Can you incorporate an input, perhaps a pushbutton, that when activated puts the outputs in the state in which you want them to start ?

cgarlow:
anyway to eliminate this freeze when uploading code?

Depends on what you're adjusting. If it's just simple numerical parameters, you can store them in EEPROM and write a routine that interacts with the Serial Monitor and lets you adjust parameters that way. Then implement some functionality in your sketch so that it knows when the values changed and can reload them from EEPROM.

Changing actual logic though? No way around that. You can't have your sketch executing at the same time as it is being overwritten.

Well...I suppose there might be one way I can think of, but it falls so far into the "advanced users only" category it's not worth explaining.