Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: PWM sine wave without "delay" on: November 05, 2012, 08:43:11 am
Ok, Great info. Thank you Holmes4 and PaulS! My project needs to be quick as it is based on an objects changing distance.
All of the "breathing" or "sleep" codes I have seen have a delay in them..Any thoughts on a code without it?
2  Using Arduino / Programming Questions / PWM sine wave without "delay" on: November 04, 2012, 04:26:00 pm
I am trying to incorporate a "Throb" or sine wave PWM pulse to this code so that outside of a predetermined length, the lights will pulse. The first part of the code I did as a version of "blink without delay" and it works great. Would the "delay" in many sine wave codes affect the serial monitor output just as blink with delay does when using If/Else?
Code:
/*
* EZ rangefinder Distance Sensor
* prints distance and changes LED flash rate
* depending on distance from sensor
* if sensor range is greater than 500 cm then..all on
*/

const int sensorPin = 5;
const int ledPinA = 9; //pin connected to LED
const int ledPinB = 10; //pin connected to LED

long value = 0;
int cm = 0;

// Variables will change:
 
int ledState = LOW;             // ledState used to set the LED BWOD
long previousMillis = 0;        // will store last time LED was updated BWOD
 
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = cm;           // interval at which to blink (milliseconds) BWOD

void setup()
{
  Serial.begin(9600);
  pinMode(ledPinA, OUTPUT);   
  pinMode(ledPinB, OUTPUT); 
 }
 
void loop()
{
  value = pulseIn(sensorPin, HIGH);
  cm = value / 20;   // pulse width is 58 microseconds per cm but modify
                     //this number to adjust blink speed relationship
  Serial.print(cm);
  Serial.print(',');
 
  if (cm < 500)
  {
   // check to see if it's time to blink the LED; that is, if the
  // difference between the current time and last time you blinked
  // the LED is bigger than the interval at which you want to
  // blink the LED.
   unsigned long currentMillis = millis();
 
   if(currentMillis - previousMillis > cm)
   {
     
    previousMillis = currentMillis; // save the last time you blinked the LED   
     if (ledState == LOW)// if the LED is off turn it on and vice-versa:
       ledState = HIGH;
     else
       ledState = LOW;
 
    // set the LED with the ledState of the variable:
     digitalWrite(ledPinA, ledState);
     digitalWrite(ledPinB, ledState);
   }
 }

  else
  {
    digitalWrite(ledPinA, HIGH);
     digitalWrite(ledPinB, HIGH);
   
  }

  }

3  Using Arduino / General Electronics / Re: MOFET selection to run 12v on: October 30, 2012, 09:01:55 pm
The project works! Thank you to EVERYONE on the forum who helped. In short: The MOSFET mentioned in the thread works but I understand not the best one out there...but it does work well.
4  Using Arduino / General Electronics / Re: MOFET selection to run 12v on: October 29, 2012, 10:46:04 am
I'll have to check and post tonight.. Thanks for the input
5  Using Arduino / General Electronics / Re: MOFET selection to run 12v on: October 29, 2012, 09:32:33 am
I tried it without and no go.  I diconnected the gate and kept the source and drain connected to the projects grounds and power was getting through and I wasn't sure why..
6  Using Arduino / General Electronics / Re: MOSFET selection to run 12v on: October 29, 2012, 09:08:05 am

Here is the link to the schematic:


http://img19.imageshack.us/img19/8075/12vschematic.jpg

Thanks for the help!
I am trying to figure out how to get an image on the forum..

7  Using Arduino / General Electronics / Re: MOSFET selection to run 12v on: October 29, 2012, 08:30:15 am
MOSFET - is what I meant to type..
8  Using Arduino / General Electronics / MOFET selection to run 12v on: October 29, 2012, 08:15:05 am
I am trying to control some LED strip lights (12V, 2 AMP) with the arduino and am trying to select the correct MOSFET to handle the load. I thought this one (http://www.vishay.com/docs/91325/sihlz14.pdf) might work but it does not. When connected with all the pull down and limiting resistors, the lights are dim. Then I noticed when I connected the Drain to Source without the gate power was getting through and dimly lighting the lights...I have researched several sites and similar projects but they do not have the same conditions.
 Any thoughts? Thanks community!
9  Using Arduino / Programming Questions / Ultrasonic sensor and IF statement on: October 23, 2012, 11:22:42 am
I have worked on this since the previous inquiry for some help. The goal is to have the LED blink quicker when an object gets closer to the sensor- (PART A) IF nothing is closer than 150 cm, the goal was to have it pulse ot thob like a mac start button (PART B) The program runs fine when an object is within 150cm, then once an object is outside of 150cm it will throb, BUT the serial monitor seems to stop or slow down making return to the PART A of the code slow and glitchy.. I'd like it to be a little more responsive and seemless.
Some construtive input is very welcome. Thank you
Code:
/*
* EZ rangefinder Distance Sensor
* prints distance and changes LED flash rate
* depending on distance from sensor
* if sensor range is greater than 150cm then LED "throbs" like apple computer
*/

const int sensorPin = 5;
const int ledPin = 6; //pin connected to LED

long value = 0;
int cm = 0;
int inches = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  value = pulseIn(sensorPin, HIGH);
  cm = value / 58;   // pulse width is 58 microseconds per cm
  Serial.print(cm);
  Serial.print(',');
 
  digitalWrite(ledPin,HIGH);
  delay(cm * 5);  //each centimeter adds 10 milliseconds delay
  digitalWrite(ledPin, LOW);
  delay( cm * 5);
  delay(20);

  if(cm > 150)
     for(int i = 0; i<360; i++){
     //convert 0-360 angle to radian (needed for sin function)
     float rad = DEG_TO_RAD * i;
 
    //calculate sin of angle as number between 0 and 255
     int sinOut = constrain((sin(rad) * 128) + 128, 0, 255);
 
    analogWrite(ledPin, sinOut);
 
    delay(10);
     }
 
}
10  Using Arduino / Programming Questions / Re: Ultrasonic EZ-1 and LED control based on distance on: October 21, 2012, 04:01:21 pm
Ah yes.
I believe I need to serial.read that number..Does that make sense?
11  Using Arduino / Programming Questions / Ultrasonic EZ-1 and LED control based on distance on: October 21, 2012, 12:04:43 pm
I am so close on this projects thank to forum input-especially CrossRoads! I am trying to have the LED blink faster when an object gets closer, then if no object is in a certain range, the LED should "throb" like and Apple computer using PWM.
The first part works ok then I tried to add the "throb" code using an "if"statement. Everything compiled fine but the throb part doesn't work..
As a relative newbie, I am looking for some insight on this code
Code:
/*
* EZ rangefinder Distance Sensor
* prints distance and changes LED flash rate
* depending on distance from sensor
* if sensor range is greater than 50000 on serial port then LED "throbs" like apple computer
*/

const int sensorPin = 5;
const int ledPin = 6; //pin connected to LED

long value = 0;
int cm = 0;
int inches = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  value = pulseIn(sensorPin, HIGH);
  cm = value / 58;   // pulse width is 58 microseconds per cm
  inches  = value / 147;  // pulse is 147 microseconds per inch
  Serial.print(cm);
  Serial.print(',');
  Serial.print(inches);
 
  digitalWrite(ledPin,HIGH);
  delay(cm * 5);  //each centimeter adds 10 milliseconds delay
  digitalWrite(ledPin, LOW);
  delay( cm * 5);
  delay(20);
 
  if (sensorPin > 50000)
     for(int i = 0; i<360; i++){
     //convert 0-360 angle to radian (needed for sin function)
     float rad = DEG_TO_RAD * i;
 
    //calculate sin of angle as number between 0 and 255
     int sinOut = constrain((sin(rad) * 128) + 128, 0, 255);
 
    analogWrite(ledPin, sinOut);
 
    delay(15);
   }
 
}

12  Using Arduino / Project Guidance / Re: Tip 122 vs. ULN2003 on: October 16, 2012, 12:20:19 pm
trying my best to digest that..
Thanks
13  Using Arduino / Project Guidance / Re: Animation Easing w servos AND steppers together on: October 16, 2012, 11:51:49 am
Happy to see you are alive sbright33..I was worried.
14  Using Arduino / Project Guidance / Re: Tip 122 vs. ULN2003 on: October 16, 2012, 11:49:35 am
Thanks CrossRoads, great input. I do want to get the right one and not add components.
I found these guys local in Miami to avoid shipping.. They have a list here of logic mosfets:
http://www.nteinc.com/Web_pgs/LL_MOSFET.html

I am trying to figure out which one... My longest strand of lights is 16' @ 36w and 3Amps..I think 2980 or 2981 would be ok..(?)
Thanks Crossroads, this has been a big help.
15  Using Arduino / Project Guidance / Re: Tip 122 vs. ULN2003 on: October 16, 2012, 10:51:37 am
CrossRoads...Is this the one?
http://www.digikey.com/product-detail/en/PI5101-00-LGIZ/1102-1078-5-ND/2774790

I bought this one: http://www.digikey.com/scripts/dksearch/dksus.dll?vendor=0&keywords=497-2766-5-nd
I may have goofed..thoughts?
Pages: [1] 2 3