upload crashes software!!

I am a complete beginner and have just uploaded my very first sketch (blink). It worked fine but I then tried to upload another sketch, but it continues to crash the environment so I have to force quit. I am using a arduino mini connected by the mini usb adaptor on a macbook leopard. Heres the sketch:

#define NUMBER_OF_PINS 4
int sensorValue;

void setup() {
Serial.begin(9600);
}
void loop() {
for(int pin=0; pin < NUMBER_OF_PINS; pin++){
sensorValue = analogRead(pin);
int range = (6797 / (sensorValue - 3)) - 4;
Serial.println(range, DEC);
delay(10);
}
}

does anybody know whats going on?
Thanks
Nic

When does the environment crash? You might try increasing the delay() from 10 to say 100 - if you send data too quickly it can overwhelm the serial monitor.

Still no luck. It crashes before it even uploads onto the board. I've tried it from different computers and it crashes the environment on all. Any ideas as to what the problem might be? Nicola

Can you be more specific? Are you pressing the upload button? What happens before the crash? How does it behave once it's crashed?

What happens if you press compile instead of upload?

It comes up with the sketch size when I compile the sketch, seems ok. I press upload (the yellow light starts flashing on the mini usb adaptor) but then it says its uploading until the program just stops responding. I've tried it a few computers and have reinstalled the environment with no luck. What should I try now? Thank you for your help btw!

Can you take a picture of your circuit / boards?

er can I direct you to my flickr page cos that didn't work! http://www.flickr.com/photos/14223379@N02/2329280207/

Can you try with different sketches? Can you try without mini connected (only with mini usb converter)? Can you try only with usb cable (with no boards connected)? Can you try with no cable connected?

Without the boards and the cable it says that the serial port cannot be found, with just the cable it's the same.

With just the usb adaptor it says problem uploading to board avrdude: stk500_recv(): programmer is not responding.

If I try another sketch nothing changes- I press upload- it says its uploading to I/O board - the RX light lights up but it stays in this state (for hours) until I force quit. Although the RX light lights up until I either turn off my computer or unplug the board. If I unplug the board the computer comes up with a warning that a serial port has been unplugged and data may be lost :-/ Is that where the problem is?

Hmm, can you try it on another computer?

Also, can you try it from the command line (Terminal)? If you set upload.verbose to true in your Arduino preferences file, you'll get the command line to use the when you upload (with the Mini USB adapter but not the Mini connected). Then try that command line with the Mini USB and Mini connected and post the output you get.

Im not all too sure of what you mean by trying the command line? Ive changed the preferences file and then uploaded to just the adaptor, this is what I got:

-Uflash:w:/Users/admin/Documents/Arduino/sketch_080313a/applet/sketch_080313a.hex:i

avrdude: Version 5.4-arduino, compiled on Oct 9 2007 at 11:22:08 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

System wide configuration file is "hardware/tools/avr/etc/avrdude.conf" User configuration file is "/Users/admin/.avrduderc" User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/tty.usbserial-A4001nWY Using Programmer : stk500v1 Overriding Baud Rate : 19200 avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding avrdude: Send: Q [51] [20] avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding

I don't know if that helps, I've tried on a different computer and it behaves in the same way.

That's perfect. What output do you get if you try uploading to the Mini itself (via the adapter as usual)?

Theres no change- gets stuck uploading still

Oh, sorry, I think I misunderstood your previous post.

When you try the upload with just the adapter connected, the first line of output (in white) should be a command line that starts with avrdude and ends with the top of the messages you posted before: -Uflash:w:/Users/admin/Documents/Arduino/sketch_080313a/applet/sketch_080313a.he x:i (and maybe a few more things).

Try running that command from the Terminal (in Application > Utilities). You'll probably need to cd to the Arduino directory first:

cd /Applications/arduino-0010

(or whatever the path is. You can just type cd and then space, and then drag the little icon at the top of the folder in the finder onto the Terminal to paste the correct path). Then run the avrdude command (with the Mini and adapter connected). It should spit out information as it tries the upload, so we can figure out where it gets stuck.

ok so I've found the white writing you were talking of and typed this as the command line

cd /Users/admin/Desktop/arduino-0010 hardware/tools/avr/bin/avrdude -Chardware/tools/avr/etc/avrdude.conf -v -v -v -v -pm168 -cstk500v1 -P/dev/tty.usbserial-A4001nWY -b19200 -D -Uflash:w:/Users/admin/Documents/Arduino/sketch_080313b/applet/sketch_080313b.hex:i

It says process completed when I press run ??

Hmm... open the Terminal. You should get a command prompt with a cursor.

Copy this in and then press return:

cd /Users/admin/Desktop/arduino-0010

Then copy this in and press return:

hardware/tools/avr/bin/avrdude -Chardware/tools/avr/etc/avrdude.conf -v -v -v -v -pm168 -cstk500v1 -P/dev/tty.usbserial-A4001nWY -b19200 -D -Uflash:w:/Users/admin/Documents/Arduino/sketch_080313b/applet/sketch_080313b.hex:i

What output do you get?

avrdude: Version 5.4-arduino, compiled on Oct 9 2007 at 11:22:08 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

System wide configuration file is "hardware/tools/avr/etc/avrdude.conf" User configuration file is "/Users/admin/.avrduderc" User configuration file does not exist or is not a regular file, skipping

Using Port : /dev/tty.usbserial-A4001nWY Using Programmer : stk500v1 Overriding Baud Rate : 19200 avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding avrdude: Send: Q [51] [20] avrdude: ser_recv(): programmer is not responding avrdude: stk500_recv(): programmer is not responding

Any ideas?

Is that with the Mini connected? Are you resetting the Mini before uploading?

I think its started to work, I've reset the board (I grounded the reset pin then connected it back to 5V) now it uploads! But.... I got alot of red text. Finishing with:

avrdude: verifying ... avrdude: 2838 bytes of flash verified avrdude: Send: Q [51] [20] avrdude: Recv: . [14] avrdude: Recv: . [10]

avrdude done. Thank you.

What does this mean??

Sounds like it's working.