Show Posts
Pages: 1 ... 33 34 [35] 36 37 ... 44
511  Using Arduino / Sensors / using interrupt and the pull up resistor on the same pin on: March 09, 2011, 11:23:41 pm
Can I use the internal pull-up resistor with an attachInterrupt at the same time on the same pin?


Code:
attachInterrupt(0, CountPulse, RISING);//turn on interrupt for flow sensor on pin 2
digitalWrite(2, HIGH);  //turn on pull up resistor for flow sensor on pin 2

Will this do away with the need of the 10K resistor in the example for this sensor:
http://www.seeedstudio.com/forum/viewtopic.php?f=4&t=989&start=0
thanks!
512  Using Arduino / Displays / LCD in Sleep mode showing zzz's on: March 09, 2011, 10:27:47 pm
Trying to figure this out, I got so tired of zzz's remaining on the screen from previous print calls, I just did this:
I'd be much obliged if someone could shorten this code up a bit!
Code:
void Hibernate(){
  /*
  Sleep mode, shows sleeping zzz's, rising and falling across the screen
  waits for keypress to awaken
  */
  srlcd.clear();  //clear screen and set cursor at home
  while(key == NO_KEY){
    srlcd.clear();
    srlcd.print("Z");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("ZZ");
    key = keypad.getKey();
    delay(100);
    srlcd.clear();
    srlcd.print("Z");
    key = keypad.getKey();
    delay(100);
   
    delay(2000);  //breathe pause
   }
  Restart_Standby(); //reset display message for hibernate exit 
}
513  Using Arduino / Displays / Re: Shiftreg alternate IC for SRLCD on: March 09, 2011, 01:32:49 am
Quote
but this 595 has a latch pin that's not even mentioned in the SRLCD
That's because the shiftregister used with the SRLCD (arduinoshiftreglcd) doesn't have a latch, it's a somewhat simpler shiftregister. The outputs reflects the data as they are shifted in directly. The '595 however can retain the old output while new data are shifted in, until a latch pulse is given.

However Nadir have a nice solution here, although it only works with the three-wire method: http://arduino.cc/forum/index.php/topic,15364.msg112755.html#msg112755
Notice the enablepin is also connected to pin 12 on the 74HC595 as well as pin 6 (enable) on the LCD.

Thanks!  This looks like the answer...
514  Using Arduino / Displays / Re: Shiftreg alternate IC for SRLCD on: March 08, 2011, 11:05:48 pm
I've looked at that, but this 595 has a latch pin that's not even mentioned in the SRLCD.  I'd like to wire it up so I can use the SRLCD.h library to simplify my LCD.
515  Using Arduino / Displays / Shiftreg alternate IC for SRLCD on: March 08, 2011, 10:52:36 pm
I'm having trouble figuring out the pinouts, I have sparkfun's shift register, (74HC595) instead of the (74LS164) Can someone please explain the pins to me, they are called different things in the data sheets.
I know Qa-Qh is the same as Q0-Q7
But the 74LS164 in the SRLCD tutorial has an A,B CLK, and CLR, that I'm not sure what they are on the 74HC595.  Then the 74HC595 has 2 extra pins (it's a 16 pin, instead of 14 pin), I'm not sure which ones I need to ground or give 5+.
Thanks,
here's the SRLCD page:
http://code.google.com/p/arduinoshiftreglcd/
and sparkfun's 74HC595 datasheet:
http://www.sparkfun.com/datasheets/IC/SN74HC595.pdf
and the 74LS164 datasheet:
http://focus.ti.com/lit/ds/symlink/sn74ls164.pdf
516  Community / Gigs and Collaborations / Need a port of LCDBarGraph to SRLCD on: March 08, 2011, 08:17:01 pm
I talked with the maker of the nice utility 'LCDBarGraph', and he said:
Quote
Theoreticaly it is possible, however I do not have the time to port the LcdBarGraph to arduinoshiftreglcd.
But feel free to make the port! You only need to find replacements to the functions I use from the LiquidCrystal library. And don't forget to publish your work smiley Cheers,

I doubt it's very hard, but it's way beyond my scope.  If someone would care to do so, I'd sure use it...
517  Using Arduino / Displays / Re: using LCD bargraph with SRLCD on: March 08, 2011, 09:08:46 am
http://arduino.cc/playground/Code/LcdBarGraph
http://code.google.com/p/arduinoshiftreglcd/
To use both of these, would the bargraph.h library have to be editted to make it work with srlcd.h, instead of liquidcrystal.h?
It looks over my head.
518  Using Arduino / Storage / eeprom settings with default on: March 08, 2011, 12:14:53 am
In the code below, how do I add a default value, so that if the settings are deleted from eeprom, a default value will be given?  I want these default values:
MySettings.lightLevel = 800
MySettings.motor_delay = 40

Code:
struct config_settings {
    int mySensVals[12];  //# of pulses in 2-12 cups
    int motor_delay;     //change the distance the platform travels
    int lightLevel;         //photocell trigger level
    boolean Enable_Audio;  //whether the user wants sound
    boolean Enable_Piezo;  //whether the user wants a knock sensor
    boolean Enable_PhotoCell;  //whether the user wants to use the photocell
} MySettings;

void LoadSettings(){
  EEPROM_readAnything(0, MySettings);   //load the settings
}

void SaveSettings(){
  EEPROM_writeAnything(0, MySettings);  //save the settings
}
519  Using Arduino / Displays / using LCD bargraph with SRLCD on: March 07, 2011, 05:42:18 pm

I've tested each one of these alone, but don't know how to use both...
I want to use these two things:
http://arduino.cc/playground/Code/LcdBarGraph
http://code.google.com/p/arduinoshiftreglcd/

I tried changing this:
Code:
LcdBarGraph lbg(&lcd, DISPLAY_WIDTH);  //LCD Bargraph
to this:
Code:
LcdBarGraph lbg(&srlcd, DISPLAY_WIDTH);  //LCD Bargraph

...with no luck.
??? 
520  Using Arduino / Programming Questions / Re: How to get length of char* string on: March 05, 2011, 10:42:05 pm
Thanks!  I've read thru the reference section listing all the functions and things I can use in this arduino language, but strlen wasn't listed in there.  Is there a complete list of functions I can use in the arduino IDE, or is that reference section pretty complete?
521  Using Arduino / Programming Questions / How to get length of char* string on: March 03, 2011, 10:38:56 pm
In the below code, I have to count the length of the string and put it in hard code.  How can I programmatically do this?  I'm only familiar with string.length(), which is different than char string...

Code:
const char* MESSAGE = "Hello World";
const int MESSAGE_LENGTH = 11;
522  Using Arduino / Storage / Re: EEprom storage using writeAnything.h on: March 03, 2011, 10:04:43 pm
Yeah, I just read the size of bolleans and integers.  strange a boolean only holds true or false, in 1 byte, and and integer at 2 bytes can hold a huge number.  I thought it would have been a lot more bytes than that.  I should be okay with all the settings I can think of changing!
523  Using Arduino / Storage / Re: EEprom storage using writeAnything.h on: March 03, 2011, 10:02:25 pm
Thanks! (that was quick).  I'll reread the ref section on sizes, an integer must be only 2 bytes, and a boolean 1, to only add up to 27...
524  Using Arduino / Storage / EEprom storage using writeAnything.h on: March 03, 2011, 09:57:30 pm
mySensVals   will be numbers anywhere from 100 to 2000
Does the Uno have enough eeprom to store this many settings?
thanks.

Code:
struct config_settings
{
    int mySensVals[12];  //# of pulses in 2-12 cups
    boolean Enable_Audio;  //whether the user wants sound
    boolean Enable_Piezo;  //whether the user wants a knock sensor
    boolean Enable_PhotoCell;  //whether the user wants to use the photocell
} MySettings;


//...set up values to save. 

    EEPROM_writeAnything(0, MySettings);  //save the settings
525  Using Arduino / Displays / Re: Advanced Scrolling on 16 x 2 LCD with user input at the same time on: March 02, 2011, 06:49:41 pm
Here's what I've finished up with:  It does work nice, and the bottom line stays put.  The LCD seems plenty clear to read.

...off the main subject, but I want to figure out how to remove the line:
Code:
const int MESSAGE_LENGTH = 60;
So that I could pass any string into this and have it programatically tell how long it is.
str.length() doesn't work with char str[], but there must be a way to tell how long str[] is?


Code:
#include <LiquidCrystal.h>

const int BACK_LIGHT = 13;                  // Pin 13 will control the backlight
const char* MESSAGE = "      Got Coffee?  Enter amount needed and press *          ";
const int MESSAGE_LENGTH = 60;
const int DISPLAY_WIDTH = 16;


/* Connections:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 */
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int nPosition = 0;
long previousMillis = 0;        // will store last time LCD was updated
long interval = 500;           // interval at which to update LCD (milliseconds)
int MyNumber = 10;      //input form serial monitor

void setup()
{
     lcd.begin(16,2);
     lcd.clear();                              // Start with a blank screen
     Serial.begin(9600);
}

void loop()
{
  unsigned long currentMillis = millis();  //get current time
 
  if(currentMillis - previousMillis > interval) {  //check if it's been long enough to shift left

      previousMillis = currentMillis;        //update last LCD write
   
         int i;
         if(nPosition < MESSAGE_LENGTH - DISPLAY_WIDTH)
         {
               for(i=0; i<DISPLAY_WIDTH; i++)
               {
                     lcd.setCursor(i, 0);
                     lcd.print(MESSAGE[nPosition + i]);
               }
         }
         
         else
         {
               int nChars = MESSAGE_LENGTH - nPosition;
               for(i=0; i<nChars; i++)
               {
                     lcd.setCursor(i, 0);
                     lcd.print(MESSAGE[nPosition + i]);
               }
   
               for(i=0; i<(DISPLAY_WIDTH - nChars); i++)
               {
                     lcd.setCursor(nChars + i, 0);
                     lcd.print(MESSAGE[i]);
               }
         }
   
         nPosition++;
         if(nPosition >= MESSAGE_LENGTH)
         {
               nPosition = 0;
         }
          lcd.setCursor(8,1);
          lcd.print(char(MyNumber));
          CheckSerial();
  }     
}



void CheckSerial(){
  if (Serial.available() > 0) {
      // get incoming byte:
      MyNumber = Serial.read();
  }
}
Pages: 1 ... 33 34 [35] 36 37 ... 44