Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 10
61  Using Arduino / General Electronics / pendulum on a string on: May 03, 2012, 10:49:32 am
Hello,

I am interested in making a 6oz pendulum swing seamlessly (i.e - no jerky motion) from a string using a motor about 12ft above...so it looks like the pendulum is in perpetual motion. I was thinking of using a DC motor with perhaps some reed switches to change the polarity of the motor with relays and an arduino to control some delays. I do not know any physics and thinking about it more and more, this seems to be a difficult task. Is this possible to do with an arduino? Is it possible at all? I couldn't find much online of anyone doing much with a pendulum from a string and a microcontroller.

Any advice as to where to go with this would be much appreciated!
62  Using Arduino / General Electronics / Re: sensor sporadically failing on: March 03, 2012, 01:27:02 pm
here is the code
i put the sensor readings throughout the loop and it's been working straight for 2 and a half hours now. Is that a fix or are there other things i could do better?
thanks so much for any feedback

Code:
int sensorBottom, sensorTop;
boolean switchTop = false;
boolean switchBottom = false;
int switchey = 1;
int unSpoolCounter = 1;
int upDown = 1;
int LED1 = 11; //all on PWM pins
int LED2 = 10;
int LED3 = 9;
int LED4 = 5;


void setup() {

  //CW is up and CC is down

  pinMode (13, OUTPUT); //DPDT relay
  pinMode(12, OUTPUT); //SPST relay

  pinMode(LED1,OUTPUT); //4 12V LEDs through tip120s
  pinMode(LED2,OUTPUT);
  pinMode(LED3, OUTPUT);
  pinMode(LED4, OUTPUT);

  pinMode (7, OUTPUT); //DPDT relay for motorBottom
  pinMode (6, OUTPUT); //spst relay for motorBottom

  Serial.begin(9600); //debug

//start by picking up
  //when everything is hi,
  //motor goes in clockwise
  //if red is in DPDT relay
  //and black is in 5v SPST relay
  digitalWrite(13, HIGH);
  digitalWrite(12, HIGH);
 

}

void loop() {
  sensorBottom = analogRead(0);
  sensorTop = analogRead(1);


  //get stuck in infinite if loops//

  //if top sensor is activated wait for 4 sec and then let down
  if ((sensorTop > 40)&&(switchTop == false)){
    //digitalWrite(13, LOW);
    digitalWrite(12, LOW);
    delay(4000);
    //flip switch
    switchBottom=false;
    switchTop=true;

  }
  if (switchTop == true) {
    //lower
    digitalWrite(13, LOW);
    digitalWrite(12, HIGH);
  }
 
  sensorBottom = analogRead(0);


  if ((sensorBottom > 10)&&(switchBottom == false)) {
    delay(100); //delay a bit because bottomSensor is too high
    digitalWrite(13, LOW);
    digitalWrite(12, LOW);

    digitalWrite(LED1, HIGH);
    delay(200);
    digitalWrite(LED2, LOW);
    digitalWrite(LED3, HIGH);
    delay(200);
    digitalWrite(LED4, LOW);
    digitalWrite(LED1, HIGH);
    delay(200);
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, HIGH);
    delay(200);
    digitalWrite(LED3, LOW);
    //2) turn on all lights and spin motor
    delay(200);
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, HIGH);
    digitalWrite(LED3, HIGH);
    digitalWrite(LED4, HIGH);

    if (switchey == 1) {
      digitalWrite(6, HIGH);
      digitalWrite(7, HIGH);
    } else {
      digitalWrite(6, HIGH);
      digitalWrite(7, LOW);
      switchey = 0;         
    }

    switchey++;
    delay(6000);

    //3)turn everything off and start over again
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, LOW);
    digitalWrite(LED3, LOW);
    digitalWrite(LED4, LOW);

    digitalWrite(6, LOW);

    switchBottom=true;
    switchTop=false;

    unSpoolCounter++;
    upDown++;
    if (unSpoolCounter > 10) {
      //if it has done so many rotations
      //pick it up a bit
      digitalWrite(13, HIGH);
      digitalWrite(12, HIGH);
      delay(500);
      //and let it unravel for ten seconds while lights pulsate
      digitalWrite(12,LOW);
      pulsate();     
      unSpoolCounter = 0;
    }
    if (upDown > 15) {
      upAnddown ();
      upAnddown ();
      upDown = 0;
    }
  }

  if (switchBottom == true) {   
    //pick UP
    digitalWrite(13, HIGH);
    digitalWrite(12, HIGH);
  }
 
  sensorBottom = analogRead(0);

}

/////////mysterious functions/////////////
void pulsate () {

  for (int i = 0; i < 7; i++) {     
    // fade in from min to max in increments of 5 points:
    for(int fadeValue = 10 ; fadeValue <= 255; fadeValue +=5) {
      // sets the value (range from 0 to 255):
      analogWrite(LED1, fadeValue);
      analogWrite(LED2, fadeValue);         
      analogWrite(LED3, fadeValue);         
      analogWrite(LED4, fadeValue);             
      // wait for 30 milliseconds to see the dimming effect   
      delay(30);                           
    }

    // fade out from max to min in increments of 5 points:
    for(int fadeValue = 255 ; fadeValue >= 10; fadeValue -=5) {
      // sets the value (range from 0 to 255):
      analogWrite(LED1, fadeValue); 
      analogWrite(LED2, fadeValue);         
      analogWrite(LED3, fadeValue);         
      analogWrite(LED4, fadeValue);             
      // wait for 30 milliseconds to see the dimming effect   
      delay(30);                           
    }

  }

  digitalWrite(LED1, LOW);
  digitalWrite(LED2, LOW);
  digitalWrite(LED3, LOW);
  digitalWrite(LED4, LOW);
}


void upAnddown () {
 digitalWrite(13, HIGH);
 digitalWrite(12, HIGH);

    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, HIGH);
    digitalWrite(LED3, HIGH);
    digitalWrite(LED4, HIGH);
 delay(2500);
 digitalWrite(13, LOW);
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, LOW);
    digitalWrite(LED3, LOW);
    digitalWrite(LED4, LOW);
 delay(1000);
 digitalWrite(13, HIGH);
 delay(2000);
 digitalWrite(13, LOW);
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, HIGH);
    digitalWrite(LED3, HIGH);
    digitalWrite(LED4, HIGH);
 delay(1500);
 digitalWrite(12,LOW);
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, LOW);
    digitalWrite(LED3, LOW);
    digitalWrite(LED4, LOW);
 delay(1000);

}
63  Using Arduino / General Electronics / sensor sporadically failing on: March 03, 2012, 10:40:34 am
Hello,

I have these two motion sensors that were given to me awhile ago. They take 10-30V (i'm giving them 12 regulated) and ouput 200mA which I have in the analog pins. I have them on voltage dividers so they don't output too much to the arduino pin...so they're outputting around 2V, giving me a steady serial reading of around 240.

I'm using the sensors for a kinetic sculpture...an object is raised by a pulley, when the top sensor sees the object, it gets lowered, when the bottom sensor sees the object it gets raised.

my problem is, is that sometimes the bottom sensor doesn't see the object and it continues to get lowered. this happens very sporadically...the motion could on for 2 hours and then all of a sudden miss a reading. if i wave my hand in front of it, it starts up again and everything continues. I need this thing to be able to run perfectly, though...for 8 hours a day for around a month.

any ideas why this sensor might not get a reading every once and awhile? any ideas for how I could tweak it so that it works better?

the code to activate the "upward motion" relays is just: if ((sensorBottom > 50)&&(switchBottom == false)) { ....

thanks so much for any help!
64  Using Arduino / General Electronics / DPDT relay on: February 11, 2012, 06:31:12 pm
Hi,

I want to control the direction of a DC motor...I was doing it with four SPST relays which I realize is dumb. I got a 12V DPDT relay and was just wondering how to hook it up. There are two coil pins, two NC pins, two "Core" (??) pins and two NO pins.
I saw this tutorial: http://arduino.cc/playground/Main/DCMotorControl and it said the wiring is wrong and I should ask about it....

So do I hook two arduino pins to the two "core" pins, the motor to the coil and the two NC pins to ground/12V and the NO pins to 12V/ground? Then I also use a transistor (like a tip120) with a diode to connect the pins to the arduino, no?

just want to make sure I'm doing it right.
Thanks.
65  Using Arduino / General Electronics / voltage divider question on: February 10, 2012, 12:30:35 pm
Hi,

I have these old motion sensors that i've hooked up to analog pins on a duemilanova. They have three wires, GND, V, and output. The only info I have on the sensors is that they take 10-30V and output max 200mA. I'm giving them a regulated 12V. On the out wire, when I put it on a multimeter and activate the sensor, I get around 14V that's going into the analog pin and it gives me a reading of 1023 in the serial monitor. So, I assume this is way too much and I'd like to lower and regulate the voltage.
I can think of two ways to do this...I could use a 7805 or I could get a couple resistors and make a voltage divider (a little cheaper and easier). I tried making a voltage divider but I was only getting a .5v reading...which is weird. I used a 1kOhm resistor with a 500ohm resistor. I connected the out wire on the sensor to the 1k resistor, another wire going from 1k resistor to arduino and also going to a 500ohm resistor that's going to ground. Is this not the correct way to do this? I was just following what I could find on the internet like the wikipedia page: http://en.wikipedia.org/wiki/Voltage_divider According to the voltage divider formula I should get getting around 4.6V...so I know I'm doing something wrong. Would a 7805 just be better and more reliable anyway?

Any advice/guidance? Thanks!
66  Using Arduino / Programming Questions / Re: i'm so bad at logic on: January 27, 2012, 05:32:33 pm
i might want to do other things so I have the code in loop. i just had to move the sensor readings down into loop. i don't know what i was thinking! it's working okay now. thanks so much for the help!
67  Using Arduino / Programming Questions / i'm so bad at logic on: January 27, 2012, 02:31:25 pm
Hi,

I'm trying to program an arduino to basically lift an object up with a motor and pulley (and some relays to control motor polarity), when the sensorTop variable gets activated, wait a few seconds, and lower the object down. when the sensorBottom variable gets activated, wait a few seconds, turn on some lights, move a second motor, and then raise the object up. again and again and again. i just can't seem to wrap my head around the logic. here's what i have so far. Any help is much appreciated!!!

Code:
//12 . 11 - pos neg
// 10 . 9 - neg pos

int sensorBottom, sensorTop;
boolean switchTop = false;
boolean switchBottom = false;

void setup() {

  pinMode(12, OUTPUT); //1st motor
  pinMode(11, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(8, OUTPUT); //2nd motor
  pinMode(7,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(4, OUTPUT);
  Serial.begin(9600);
  sensorBottom = analogRead(1);
  sensorTop = analogRead(0);

}

void loop() {

  //start by picking up??
  //digitalWrite(12, HIGH);
  //digitalWrite(11, HIGH);
  //digitalWrite(10, LOW);
 // digitalWrite(9, LOW);

  //get stuck in infinite if loops//

  //if top sensor is activated wait for 4 sec and then let down
  if ((sensorTop > 500)&&(switchTop == false)){
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    delay(4000);
    //flip switch
    switchBottom=false;
    switchTop=true;

  }
  if (switchTop == true) {
    //lower
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, HIGH);
    digitalWrite(9, HIGH);

  }


  if ((sensorBottom > 500)&&(switchBottom == false)) {
    delay(2000);
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
    digitalWrite(7, HIGH);
    delay(200);
    digitalWrite(7, LOW);
    digitalWrite(6, HIGH);
    delay(200);
    digitalWrite(6, LOW);
    digitalWrite(5, HIGH);
    delay(200);
    digitalWrite(5, LOW);
    digitalWrite(4, HIGH);
    delay(200);
    digitalWrite(4, LOW);
    //2) turn on all lights and spin motor
    delay(200);
    digitalWrite(8, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(5, HIGH);
    digitalWrite(4, HIGH);
    delay(3000);
    //3)turn everything off and start over again
    digitalWrite(8, LOW);
    digitalWrite(7, LOW);
    digitalWrite(6, LOW);
    digitalWrite(5, LOW);
    digitalWrite(4, LOW);
    switchBottom=true;
    switchTop=false;
  }

  if (switchBottom == true) {   
    //pick UP
    digitalWrite(12, HIGH);
    digitalWrite(11, HIGH);
    digitalWrite(10, LOW);
    digitalWrite(9, LOW);
  }

}
68  Community / Exhibition / Gallery / Re: piano cube light painting on: October 15, 2011, 04:08:53 pm
Thanks! Here's the youtube url: http://www.youtube.com/watch?feature=player_embedded&v=DUm8HYax6mI

i made a painting with key sensitivity awhile ago :-)
here:
http://www.jeremycouillard.com/blog/03172010/

the Vf of the leds is 3.4 and they are 300mA...according to this (http://led.linear1.org/1led.wiz)  led calculator...i needed 33Ohm, 3W resisitors (huge ones!)
the schematics are pretty simple...just 9 tip120s, each one controlling 5 LEDs...3 pots...each one controlling 3 tip120s...
69  Community / Exhibition / Gallery / piano cube light painting on: October 14, 2011, 10:21:01 am
Hi,

I recently finished a painting with light emanating from it using an atmega328 with arduino bootloader.



i used 12v leds with some tip120s to switch them on and off. it's a real bird's nest behind the painting. hopefully nothing will get set on fire :-) I used really big resistors (3W) but they still get very hot.
Here' s more info on my blog: http://www.jeremycouillard.com/blog/10142011/

Thanks so much! I couldn't make stuff like this without the forums here!!!
70  Using Arduino / General Electronics / Re: 4 servos one uno chip on: October 01, 2011, 09:46:27 am
hi,
thanks for your help...so since they take 700mA at stall current...one 7805 is not enough? what is the difference between stall current and running current at no load? why would stall current take so much more amperage than running current? if a 7805 is not enough to power these do i just need an adapter that is 4.8-6v and gives out like 3.5A? do those even exist? or would i need to power each servo separately?

thanks
71  Using Arduino / General Electronics / 4 servos one uno chip on: September 30, 2011, 03:22:01 pm
Hi,

If I am powering an atmega328 with a 7805 voltage regulator...is it okay to also power the 4 servos I am controlling with that power? Or do I need to power them with something separate? I am not so familiar with how servos work exactly. I know each one takes 160mA or 60mA when it is idle...the atmega takes 25mA...the 7805 gives 500mA. So this should be okay? (I wouldn't ever be controlling all four at once...just one or two at a time max)

The servos I am using are here: http://users.ece.utexas.edu/~valvano/Datasheets/ServoHS311.pdf

Thanks for any feedback
72  Using Arduino / General Electronics / resistor heat on: September 30, 2011, 10:19:31 am
Hi,
I've been googling around but I couldn't find a satisfactory answer....

I have 5 LEDs set up in parallel being powered by a 12v/3A regulated supply (eventually to be controlled by an arduino through a TIP120 transistor)...the LEDs have a Vf of 3.5 and draw 35mA...an LED calculator online told me to use 270ohm, 1W resistors. When I power everything up...the resistors get pretty hot to the touch after a few minutes. This is a circuit that will be on for up to 8 hours at a time. Is this okay to have the resistors be so hot? I know that's what they do....but it almost seems like they might melt...or burn something else....

here is a little drawing of the circuit: http://dl.dropbox.com/u/7072449/led_circuit.jpg

thanks for any advice

73  Using Arduino / General Electronics / Re: 5 LEDs in one pin with a transistor on: September 21, 2011, 07:07:01 pm
Hi thanks for much for the help,

I always try to be as specific as possible...but I guess I always forget some detail...sorry about that....but yes...I want 5 LEDs in one pin and to control them all together...NOT independently. It's just something as simple as turning all 5 off at once and all 5 on back again.

Running the arduino blink sketch, I tried switching the transistors around with emitter and collector...when I did that two lights were very dim and one was half as bright...I tried a TIP 120 (wiring everything a little different because the pin configurations are different) and same thing...just very bright lights but no HIGH to LOW, I also tried a PNP as well...the NPN I was mostly messing around with was, I believe a 2N4400 or something like that...I don't have it with me at the moment...

so with a mosfet...do you mean something like this?: http://www.sparkfun.com/products/10213

why don't they use a mosfet in that adafruit tutorial? or are they? they make it seem easy with just a normal transistor...

thanks so much for any other ideas...
74  Using Arduino / General Electronics / 5 LEDs in one pin with a transistor on: September 21, 2011, 04:49:48 pm
Hi,

I know this has been brought up before...but the answers don't seem to make much sense for me.

Basically I just want to be able to control about 5 LEDs in one arduino pin. Just be able to turn them on and off. I can power the LEDs not from the arduino. I have an unregulated power supply...(12v but the multimeter says 20v) I can get a regulated one...but anyway...I know I can do this with a transistor. I just can't find any schematics that make sense to me. I found this one: http://forums.adafruit.com/viewtopic.php?f=8&t=16469#p82745
but I don't understand how to wire everything up. So if I have an NPN transistor...the arduino goes in pin 2 (base), pin 1 (emitter) goes to cathode in the 5 LEDs, pin 3 (collector) goes to ground through a resistor. the 12V (or 20V) goes in the anode of the LEDs. I would also need resistors on the LEDs, correct? Wouldn't I also need a resistor from base pin of the transistor to the arduino? I tried 1k, 10k, etc and still...the LEDs just light up very bright and the transistor gets very hot. I also tried this with a TIP120 transistor with the same result.
Do I need a diode somewhere?
The Vf of the LEDs is 3.5. I don't know how much mA they take...I just got a bag of them from a friend....he told me they were "12v LEDs"...

thanks so much for any help...I hope that I am being clear with everything...
75  Using Arduino / General Electronics / Re: stereo sound on: August 29, 2011, 03:23:02 pm
thanks for your help...what do you mean by shortcut? do I just connect the right speaker and left speaker pins together and i'll get double mono?

thanks!
Pages: 1 ... 3 4 [5] 6 7 ... 10