arduino to high voltage

Ehi guys...this is a really simple sketch, that enables 3 led and a high voltage device, in my case a small air pump.

I linked to that by a power supply with usb.

int pump = 7; // Arduino pin for the air pump int ledR = 11; // red led int ledY = 10; // yellow led int ledG = 9; // green led //int button = 7; // Switch connected to digital pin 2 int val;

void setup() { Serial.begin(9600); // Port used pinMode(pump, OUTPUT); // list of output pinMode(ledR, OUTPUT); pinMode(ledY, OUTPUT); pinMode(ledG, OUTPUT); //pinMode(button, INPUT); // for simulating the microphone

}

void loop() { if (Serial.available()) { val = Serial.read(); if (val == 'c') { // If you press "c" on the keyboard digitalWrite(7, HIGH); // you turn on the pump digitalWrite(9, HIGH); // you turn on the green led delay(2000); // for two seconds digitalWrite(7, LOW); digitalWrite(9, LOW); delay (200); } if (val == 'o') { // If you press "o" on the keyboard

digitalWrite(7, HIGH); // you turn on the pump digitalWrite(10, HIGH); // you turn on the yellow led delay(4000); // for four seconds digitalWrite(7, LOW); digitalWrite(10, LOW); delay(200);

} if (val == 'e') { // If you press "e" on the keyboard

digitalWrite(7, HIGH); // you turn on the pump digitalWrite(11, HIGH); // you turn on the red led delay(6000); // for six seconds digitalWrite(7, LOW); digitalWrite(11, LOW); delay(200);

}

}

}

I don't know why it has worked for some minute..several trials...and now it doesn't. I provided also an exernal power supply for the arduino, but i think it useless. I have to plug it in the computer, because also of the Processing sketch.

What can i do? :-/

P.S. Both on arduino diecimila and duemilanove.

thanks for your time :o

and now it doesn't

Give us a hint. What doesn't work?

What do you physically have connected to pin 7?

the leds work, but the air pump not.

I’ve used a usb adaptor (4 pin…which the first is linked to the pin 7 arduino, and the last to the common ground).

In the meanwhile the air pump plug is on the power supply.

I could listen such a “tac” when the pump should work.

Just for debugging, if i plug it directly to the usb in the computer, it works fine.

What is the current rating on the pump? It problebly to much for the arduino to power. If you place a led in place of the pump does that work?

yep.. i've changed the pin another time..now it's the 2.

Hope it will keep to work :)

thanks guys ;)

i've changed the pin another time..now it's the 2

Until you've identified the problem with pin 7, you may just have condemned pin 2 as well.

What sort of switch (relay/transistor...) have you got between the Arduino and the pump?

What sort of switch (relay/transistor...) have you got between the Arduino and the pump?

Sounds like none :o. Also sounds like he's fried Pin 7 (and soon pin 2 as well)..

EDIT: Actually, if an LED still works on Pin 7 perhaps not. Maybe the OP meant that it worked on pin 2 (the new one)..

i used a power supply with usb and normal plug. It works as an AND port.

Take that for granted...now i think i really fixed my problem.

I had to clear the port in processing after each command.

myPort.clear();

now it's ok :)

Thanks to everybody. ;)