Show Posts
Pages: 1 ... 37 38 [39]
571  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Fade LED in & out without interruptions ? on: August 13, 2008, 10:36:06 am
Thanks guys.  Here is my code.
I have put the fading led as the continually running code with checking for the temp as a sort of subroutine.  It should now continually fade the led in and out while periodically checking for the temperature. Did I get this right?


// LM35 Temperature Sensor and LCD 

#include <LCD4Bit.h>                                                                   // use of LCD4Bit library
                                                                              //create object to control an LCD.  
                                                                        //number of lines in display=2
LCD4Bit lcd = LCD4Bit(2);                                                       // create object to control an LCD # of lines in display=2

 int inPin = 5;                                  // select the input pin for analog temp value
 int inVal;                                     // integer value for input read from sensor
 int i;
 int samples[8];                                    // variables to make a better precision
 long interval=4000;
 long previousMillis =0;
 
void setup() {
  pinMode(13, OUTPUT);                                                              // set LED pin
  digitalWrite(13, HIGH);                                                       // light the  LED
  Serial.begin(9600);                             // set up Serial library at 9600 bps
  lcd.init();                                                                   // initialize LCD
  lcd.printIn("Welcome to my" );
  lcd.cursorTo(2, 0);                                                              // move cursor to line 2 position 0
  lcd.printIn("secret lab");
  delay(3000);
}

void loop()
{
  for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)
  {
    analogWrite(13, value);           // sets the value (range from 0 to 255)
                                      // waits for 30 milli seconds to see the dimming effect
  }
  for(value = 255; value >=0; value-=5)   // fade out (from max to min)
  {
    analogWrite(13, value);
    
  }  


      void TempTake()
      {  
       if (millis() - previousMillis > interval) {
                                previousMillis = millis();
            for(i = 0;i<=7;i++){                      // gets avg of 8 samples of temperature
             samples= ( 5.0 * analogRead(inPin) * 100.0) / 1024.0;
             inVal = inVal + samples;
             }
              inVal = inVal/8.0;                  
              lcd.clear();
              char buf[12];                                                             // "-2147483648\0" set buffer for itoa
              lcd.printIn(itoa(((inVal * 9)/ 5 + 32), buf, 10));        
              lcd.printIn(" Fahrenheit");
              lcd.cursorTo(2, 0);                                  // move cursor to line 2 position 0
              lcd.printIn(itoa((inVal), buf, 10));            // convert to string
             lcd.printIn(" Celsius");                                    lcd.leftScroll(20, 30);      // scroll dis 20 chars to left, delaying 30ms each
             inVal = 0;                                                 
            }
      }
}
572  Forum 2005-2010 (read only) / Frequently-Asked Questions / Fade LED in & out without interruptions ? on: August 12, 2008, 03:16:28 pm
Hi- Another newbie question.
I want to do 2 things at once and a looking for the best wayto do this.

I have a program that gets a reading and prints it to an LCD screen.  There is then a delay so the screen can be read before it is cleared.  The process then repeats itself.

While this is going on I want to have an LED lit, to indicate everyhting is working.  I want to fade the led in and out usingthe code below.  

How do I make the LED continually fade in and out without being interrupted bythe rest of the program, such as the delay for the screen to be read?

Is this something called an interrupt?

void loop()
{
  for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)
  {
    analogWrite(ledpin, value);           // sets the value (range from 0 to 255)
    delay(30);                            // waits for 30 milli seconds to see the dimming effect
  }
  for(value = 255; value >=0; value-=5)   // fade out (from max to min)
  {
    analogWrite(ledpin, value);
    delay(30);
  }  
}
573  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: LCD Backlight on: August 07, 2008, 06:27:51 pm
Hi - Thanks for the advice.  Here are some of the specs from the datasheet.
Can I just connect a resistor and an on off type button between pin 15 and pin 1?

1. 5X8 dots with cursor
2. Built-in controller (KS0066U or Equivalent)
3. +5V power supply(Also available for +3.0V)
4. 1/16 duty
5. BKL to be driven by pin1,pin2,or pin15,pin16,or A,K
6. N.V.optional

Pin #  Symbol    Function
1.        VSS       GND
2.        VDD       +5V
15.        A        +4.2V for LED
16.        K        Power supply for BKL(0V)

574  Forum 2005-2010 (read only) / Frequently-Asked Questions / LCD Backlight on: August 07, 2008, 06:19:11 am
Hi,
I have got an 16X2 LCD HD44780 form Spark Fun working that shows a temperature reading.  I am using the LCD 4 bit library and it works fine.  My question is , how do I turn on backlighting?  I believe this is available on pins 15 & 16 from the LCD.

Thanks
575  Forum 2005-2010 (read only) / Frequently-Asked Questions / Re: Voltage Question on: August 08, 2008, 06:13:23 am
Thanks for the hints.  One thing I forgot to mention is that the change is instant, meaning I have to adjust the pot to see the LCD screen clearly when switching to the 9 volt battery.  The change in temp is about 10 degrees fahrenheit.
I'll try playing around with it this weekend.
576  Forum 2005-2010 (read only) / Frequently-Asked Questions / Voltage Question on: August 07, 2008, 06:45:54 pm
Hi,
I'm using an LM35 sensor to get a temperature reading and view it on an LCD screen.
I get a lower reading when the power is supplied with a USB cable by my computer and a higher reader when power is supplied by a 9v battery.  If all of the power is supplied by the 5 volt pin ,why would my power source make a difference?

Thanks.
577  Forum 2005-2010 (read only) / Bar Sport / Re: Your last purchase? on: November 22, 2010, 12:45:54 pm
An LCD Backpack from Adafruit.  A gazillion wires down to four.  http://www.adafruit.com/index.php?main_page=product_info&cPath=37&products_id=292&zenid=5fe9b502beb4da1d153d15853d5add0e

Time to clean up an old project and get rid of the rats nest of wires.
578  Forum 2005-2010 (read only) / Bar Sport / Re: Is there many British shows on US TV? on: December 22, 2010, 03:22:11 pm
The new Law & Order UK is a great show if you like police shows.
579  Forum 2005-2010 (read only) / Bar Sport / Re: Shelf Stocking Robot?? on: November 04, 2010, 12:02:45 pm
This isn't exactly what you are looking for , but still pretty cool.

http://www.kivasystems.com/

I saw a demo once by Kiva Systems.  These robots basically work by bringing the shelves to the box packer.  CVS decided to expand a warehouse they had with these robots in it and the robots did all the moving and  setting up in the new added on space!

Also, the sytem is completely dynamic, as in each shelve goes where it is most needed and doesn't have a home space.
580  Forum 2005-2010 (read only) / Bar Sport / Re: Maker Faire NYC on: August 22, 2010, 01:52:16 pm
Awsome - Massimo and Tom Igoe will be there.  Love Tom's book Making Things Talk.  I did the making a cat tweet experiment from that book.

Jezuz - Ladyada/Adafruit is from NYC.
581  Forum 2005-2010 (read only) / Bar Sport / Re: Maker Faire NYC on: August 20, 2010, 01:30:40 pm
Yes!
I hope Adafruit is there as well.
582  Forum 2005-2010 (read only) / Bar Sport / Re: Your dream electronics lab? on: August 25, 2010, 11:37:23 am
Seems like you thought of everything especially fume extraction.  One thing I have found important is proper lighting, especailly when dealing with tiny parts or trying to read labels or numbers on parts.

Oh, since this is a dream lab how about a robot that serves you beer?
583  Forum 2005-2010 (read only) / Bar Sport / Workbench suggestions? on: August 19, 2010, 03:05:51 pm
I have recently cleaned out my basement and now have room for an electronics workbench.  My current workbench I made out of wood and it is used for manner of things like sawing, sanding, soldering etc..

I am looking to get a second workench just for electronics projects.  
What does everone here use? Any suggestions or favorite workbenches?
584  Forum 2005-2010 (read only) / Bar Sport / Re: Why I like the Arduino on: August 13, 2010, 09:37:45 am
I learned BASIC on a Trash 80 in high school.  The highlight was a game I made that was like a slot machine .  You placed a bet and pulled the "handle".  I actaully tried to sell it for a couple of bucks on ... wait for this... a cassette tape!

Programminng an Arduino on a MAC is so much easier.
Pages: 1 ... 37 38 [39]