Show Posts
Pages: 1 ... 3 4 [5] 6 7 ... 9
61  Using Arduino / Programming Questions / Re: LED won't shut off completely. on: May 01, 2012, 01:51:35 pm
the circuit just asks for power transistors. tip122 would work just as fine. i am setting the voltage to 0, using an analog write function, i.e.

analogWrite(led, 0);
62  Using Arduino / Programming Questions / Re: LED won't shut off completely. on: May 01, 2012, 10:30:34 am
I've been dimming them with PWM. and have tested a digital write to it. same results.
63  Using Arduino / Programming Questions / LED won't shut off completely. on: May 01, 2012, 10:06:26 am
so i followed this LED strip tutorial: http://www.ladyada.net/products/digitalrgbledstrip/index.html

basically I've followed the circuit with the TIP 122 transistor, and I'm trying to fade between 3 led strips. they all work, except one of the strips will not completely turn off. I'm not sure if anyone has some quick suggestions/tips why this might be happening.

the code has been tested and works fine with lower voltage LED's. I've adjusted the circuit to take into an account an external power supply instead of the Arduino power due to low amperage and not enough voltage.

help?
64  Using Arduino / Programming Questions / Re: compare sensor data range over time to shut off on: April 27, 2012, 01:53:58 pm
when the sensor stays a certain range for "x" amount of time, turn off. else, leave on.
65  Using Arduino / Programming Questions / Re: compare sensor data range over time to shut off on: April 27, 2012, 01:21:40 pm
when the sensor data stays the same over a range of time, turn led off. when it doesn't, turn on
66  Using Arduino / Programming Questions / Re: compare sensor data range over time to shut off on: April 27, 2012, 01:11:19 pm
i want the led off if the sensor reading stays at same value for "x" amount of time. if not, then i want it to be high. thats all. i can't get this logic down
67  Using Arduino / Programming Questions / Re: compare sensor data range over time to shut off on: April 27, 2012, 12:16:38 pm
trying to apply it to my code. not making sense. this is what i have:

Code:
//do our logic test
    if(oldDistance > newDistance)
      {
        digitalWrite(blue,HIGH);
      lastClosed = time;
      }
      else
    if((time - lastClosed) > (openTimeout ))
      {
       
        digitalWrite(blue,LOW);
      }

    }
68  Using Arduino / Programming Questions / Re: compare sensor data range over time to shut off on: April 27, 2012, 10:27:14 am
I'm trying to disect your code, without much luck or understanding. am i on the right track with how I'm going about my sketch? something I'm missing? the time read just becomes continous and i want it to obviously change the second the new distance value changes. i know I'm missing somethingg quick but i can't get it.
69  Using Arduino / Programming Questions / Re: compare sensor data range over time to shut off on: April 27, 2012, 10:07:56 am
Code:
int ultraSoundSignal = 8; // Ultrasound signal pin
int val = 0;
int oldDistance;
int newDistance;
int timecount; // Echo counter
int ledPin = 5;
int red = 9;
int blue = 10;
int count = 0;
unsigned long start, finished, elapsed;

void setup() {
 Serial.begin(9600);
 pinMode(ledPin, OUTPUT);
 int oldDistance = 0;
 pinMode(red,OUTPUT);
 pinMode(blue,OUTPUT);
//  oldDistance = read_the_sensor();
}
void displayResult()
{
  float h,m,s,ms;
  unsigned long over;
  elapsed=finished-start;
  h=int(elapsed/3600000);
  over=elapsed%3600000;
  m=int(over/60000);
  over=over%60000;
  s=int(over/1000);
  ms=over%1000;
  Serial.print("Raw elapsed time: ");
  Serial.println(elapsed);
  Serial.print("Elapsed time: ");
  Serial.print(h,0);
  Serial.print("h ");
  Serial.print(m,0);
  Serial.print("m ");
  Serial.print(s,0);
  Serial.print("s ");
  Serial.print(ms,0);
  Serial.println("ms");
  Serial.println(); 
}

    void loop() {
      if(timecount > 0){
      digitalWrite(ledPin, HIGH);
    }

      oldDistance = read_the_sensor();
   
              delay(300);
      newDistance = read_the_sensor();
 

    //newDistance = timecount; //  echo pulse time to newDistance
    Serial.print("New Distance  = "); // Example identifier for the sensor
    Serial.print(newDistance);
    Serial.write(10);
    Serial.write(13);

    //oldDistance = timecount; //  echo pulse time to newDistance
    Serial.print("Old Distance  = "); // Example identifier for the sensor
    Serial.print(oldDistance);
    Serial.write(10);
    Serial.write(13);
   

    /* Lite up LED if any value is passed by the echo pulse
     * -------------------------------------------------------------------
     */
if (newDistance =! oldDistance){
    start=millis();
    delay(200); // for debounce   
    Serial.println("Started...");

    //digitalWrite(led, HIGH);
   
}else{
 
   
    finished=millis();
    delay(200); // for debounce
    displayResult();
   
}}
 
 
 
  //    //do our logic test
//    if(oldDistance > newDistance)
//      {
//        digitalWrite(red,HIGH);
//        digitalWrite(blue,LOW);
//      }
//      else
//    if(oldDistance < newDistance)
//      {
//        digitalWrite(red,LOW);
//        digitalWrite(blue,HIGH);
//      }
//
//    }



int read_the_sensor() {
timecount = 0;
val = 0;
pinMode(ultraSoundSignal, OUTPUT); // Switch signalpin to output

/* Send low-high-low pulse to activate the trigger pulse of the sensor
* -------------------------------------------------------------------
*/

digitalWrite(ultraSoundSignal, LOW); // Send low pulse
delayMicroseconds(2); // Wait for 2 microseconds
digitalWrite(ultraSoundSignal, HIGH); // Send high pulse
delayMicroseconds(5); // Wait for 5 microseconds
digitalWrite(ultraSoundSignal, LOW); // Holdoff

/* Listening for echo pulse
* -------------------------------------------------------------------
*/

pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input
val = digitalRead(ultraSoundSignal); //  signal value to val
while(val == LOW) { // Loop until pin reads a high value
 val = digitalRead(ultraSoundSignal);
  }

while(val == HIGH) { // Loop until pin reads a high value
 val = digitalRead(ultraSoundSignal);
 timecount = timecount +1;            // Count echo pulse time
  }

return timecount;
}
70  Using Arduino / Programming Questions / Re: compare sensor data range over time to shut off on: April 27, 2012, 09:48:03 am
Quote
If it is the same, you need to compare the time since the change (Hint: Millis() - timeSinceChange) to see if it's greater than a certain interval.

i want to summarize that when this sensor value has not changed over a specific period of time, do something. I'm not understanding how what i quoted will do that. i may be wrong. i can't visually understand it.
71  Using Arduino / Programming Questions / Re: compare sensor data range over time to shut off on: April 26, 2012, 01:10:53 pm
PaulS, im unclear then how to implement millis.

code thus far:


Code:
int lastVal = 0;
unsigned long change = 0;
int signalPin = 8;     
long elapsedtime = 0;

int led = 5;
void setup()
{

  Serial.begin(9600);
}




void loop()
{

  elapsedtime = 0;
  pinMode(signalPin, OUTPUT);

  // Send 0-1-0 pulse to activate the sensor
  digitalWrite(signalPin, LOW);
  delayMicroseconds(2);
  digitalWrite(signalPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(signalPin, LOW);

  // Listen to pulse
  pinMode(signalPin, INPUT);               
  elapsedtime = pulseIn(signalPin, HIGH);

  // print value through Serial

  Serial.println(elapsedtime, DEC);


  int valueCurrent = digitalRead(signalPin);
  if (valueCurrent =! lastVal) {  //should lastval be millis?

    digitalWrite(led, HIGH); //do something

  }
  else {

    digitalWrite(led, LOW);

  }
}
72  Using Arduino / Programming Questions / Re: compare sensor data range over time to shut off on: April 26, 2012, 01:06:37 pm
how would i reset millis() ?  how to apply it to sensor pin? I've read documentation and understand it, but i can't grasp how to apply it. to reset... and then it seems like i need some more logic?
73  Using Arduino / Programming Questions / Re: compare sensor data range over time to shut off on: April 26, 2012, 09:10:29 am
so i did a little quick mach up but i know I'm missing some key parts. I'm just confused on specific syntax to use. heres what i got:

Code:
boolean lastVal = 0;              //last reading
int change = 0;   

int sensorPin = 8;

if(sensorPin =! lastVal ){

//blink led or whatever action

}
else {

change //confused here on how to set the "change to now". use millis?

}
74  Using Arduino / Programming Questions / compare sensor data range over time to shut off on: April 25, 2012, 05:32:06 pm
I'm trying to compare if a sensor datas range stays the same over "x" amount of time, to do something. I'm kinda struggling on the syntax, so any help would be great. heres a basic ping sensor code I'm using:


Code:
int signalPin = 8;     // sensor signal pin connected to wiring pin 0
long elapsedtime = 0;

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  elapsedtime = 0;
  pinMode(signalPin, OUTPUT);  // set signalPin as OUTPUT

  // Send 0-1-0 pulse to activate the sensor
  digitalWrite(signalPin, LOW);
  delayMicroseconds(2);
  digitalWrite(signalPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(signalPin, LOW);

  // Listen to pulse
  pinMode(signalPin, INPUT);               // set signalPin as INPUT
  elapsedtime = pulseIn(signalPin, HIGH);  // get the length of the pusle while it is HIGH

  // print value through Serial

  Serial.println(elapsedtime, DEC);
  delay(100);
}
75  Using Arduino / Programming Questions / Re: bitshift mapping a number with sine wave generator on: April 20, 2012, 02:31:23 pm
http://arduino.cc/en/Reference/Bitshift

basically its shifting within binary. i think. i mentioned the line of code from my sketch, which was this:

 phaccu=phaccu+tword_m; // soft DDS, phase accu with 32 bits
 
  icnt=phaccu >> 24; //  this number, 24, i want to be able to become adjustable with mapped values from a pot with a min or 1 and max of 28.

hope this clarified a bit.
Pages: 1 ... 3 4 [5] 6 7 ... 9