Show Posts
Pages: 1 ... 38 39 [40] 41 42 ... 44
586  Using Arduino / Storage / What is the 'config_t'? on: February 18, 2011, 04:31:27 pm
The code I'm working with:
http://www.arduino.cc/playground/Code/EEPROMWriteAnything

I know it works, but if I can understand HOW, it'll be way better. So...
There's no mention of 'struct' in the reference pages, but I understand that it makes something like a group variable.  What is the 'config_t'?  I couldn't find much googling it.
struct config_t
{
    long alarm;
    int mode;
} configuration;

587  Using Arduino / Motors, Mechanics, and Power / Re: does a detached servo with power sraw current? on: February 18, 2011, 08:46:05 am
The reason for this question:  I'm still hoping to just use a servo to open and close a drawer (the drawer is actually a platform on which a coffee pot sits in a cupboard).  I know a servo is not designed to be used this way, but it would save having to rig up extra sesnors/limit switches, and a servo is easy to use. Being it's just used a few seconds a day thing, maybe it'll work for years. 
Here's my first run at code for it.  Does it look promising?
Code:
/* servo speed:
0    full speed reverse
90   stopped
180  full speed forward
*/
Servo myservo;  // create servo object to control a servo
 
void Servo_Out()
{
  myservo.attach(ServoPin);  // attaches the servo on pin 9 to the servo object
  lcd.clear();
  lcd.print("1 coffeepot coming up, er, out.");

   int intDelay = 20;  //changing delay will change the overall distance.
   int x = 1;
   for (int i = 91; i > 90; i = i + x){  //loop from 90 to 179 and back to 90
      myservo.write(i);     // sets the servo speed
      if (i = 179) x = -1;  // start to slow down at full speed
      delay(intDelay);  // set distance to 0.5" longer than drawer travel
   }
  myservo.detach();  // detaches the servo on pin 9 to the servo object
}
588  Using Arduino / Motors, Mechanics, and Power / does a detached servo with power sraw current? on: February 17, 2011, 11:44:02 pm
Code:
  myservo.detach(ServoPin);  // detaches the servo on pin 9 to the servo object
If you detach a servo, but still have the Gnd & +5 volts wires hooked up, is it drawing any current or holding it's current position?
589  Using Arduino / Programming Questions / sending flow back to the Loop() on: February 17, 2011, 06:53:55 pm
It seems I can't just add the line somewhere in a function
Loop;
and have it go back to the Loop() routine?

I put a label first thing in the Loop() routine called
StandbyLoop:
but my reference to it later (goto StandbyLoop;) comp\iles with 'label used, but not defined'
???
590  Using Arduino / Sensors / setting a pin high the 2nd time on: February 17, 2011, 05:53:18 pm
Does it hurt anything to do this:
  digitalWrite(SolenoidPin, HIGH);  //turn on the water valve
...if the pin was already high?
591  Using Arduino / Programming Questions / Re: Different Tabs on: February 17, 2011, 09:29:07 am
What is the purpose of the #ifdef and the #endif do in your sketch?
Code:
#ifdef stand-alone
// Stand-alone photogate setting
#define button1_pin 11 //enter
#define button2_pin 13 //down pause
#define button3_pin 12 //up unpause
#define button4_pin 10 //Escape
#define gate0_pin 15
#define gate1_pin 14
#define gate2_pin 17
#define gate3_pin 16
#endif

592  Using Arduino / Programming Questions / Re: Different Tabs on: February 17, 2011, 08:45:38 am
Thanks for the tone sketch.  I'm gonna really like breaking things into tabs.  Thanks for the blog luidr.
593  Using Arduino / Programming Questions / Re: Different Tabs on: February 16, 2011, 09:18:31 pm
Thanks!
ps.  I'm looking for a little melody tune player, which where you using?
594  Using Arduino / Sensors / Re: Understanding 'Analog Buttons' on: February 16, 2011, 08:42:05 pm
...I'll be working on a Flow Chart in Excel, be back later, but I still hope someone answers my previous post, I think I'm correct in the way I understand it.
A flow chart is a very good idea, thanks.
595  Using Arduino / Sensors / Re: Understanding 'Analog Buttons' on: February 16, 2011, 08:26:38 pm
Am I correct that analogButtons.checkButtons();
should be in my Loop routine, and then in the function
void handleButtons(int id, boolean held)
is where I actually put the commands to call different routines, depending on which button was pressed?
596  Using Arduino / Programming Questions / Re: Different Tabs on: February 16, 2011, 08:20:32 pm
So for now, just learning, I can add additional tabs and when I name them, add .pde to the name.  Then when I compile, it will be like they are all together as one sketch. (Variable references in other tabs will work fine)
This will help organization.
597  Using Arduino / Programming Questions / Different Tabs on: February 16, 2011, 06:01:25 pm
Can I put code on different tabs, to help keep it organized?  Is there some help/tutorial on this somewhere?  I can't find any
598  Using Arduino / Sensors / Re: Understanding 'Analog Buttons' on: February 16, 2011, 05:30:50 pm
http://www.arduino.cc/playground/Code/AnalogButtons

...sorry, I thought everybody but me knew what they were, where the library was, and had used them numerous times.  But upon googling 'AnalogButtons.h' I see I'm like the 2nd person that knows this library exists.



Here's the sample code, I'm just hoping for a little more insight on how it works.
Code:
/*
  AnalogButtons,
 
  created 02 Jan 2009 V 0.1
 
 Connect more than one button to a single analog pin,
 register a call-back function.which gets called when a button
 is pressed or held down for the defined number of seconds. Includes
 software key debouncing which may need to be adjusted, the the second
 argument to AnalogButtons class. Define the ANALOG_PIN in the constructor
 of AnalogButtons.
 
 The circuit:

 * 5 buttons, 1 side of all buttons connected together to +5V.
   The other side of each button is connected via a different value
   resister (tested with) 1k, 2k5, 5k8, 10k, 18k to one side of a
   100k resister which is in turn connected to GND. At the point
   where all the different resisters are joined you make a connection
   to your analog input. Basicly a different voltage divider is setup
   depending upon which button is pressed. You have to configure the
   Buttons Hi/Low values, see the comments in example code below and the
   AnalogButtons::configure(ANALOG_PIN) function.
   
   More or less than 5 buttons could be added, just pick different values
   of the resister sot hat all buttons have different values which arn't too
   close in size.
   
   I'm not sure what happens when Arduino is powered from batteries and Power V
   drops below V5.
 
 by Neil DUdman and everyone who's ever used Arduino
 
 */
#include "AnalogButtons.h"

#define ANALOG_PIN 0

// A call back function that you pass into the constructor of AnalogButtons, see example
// below. Alternitivly you could extend the Button class and re-define the methods pressed()
// or held() which are called
void handleButtons(int id, boolean held)

  if (held) {
    Serial.print("button id="); Serial.print(id); Serial.println(" was pressed and held");
  } else{
    Serial.print("button id="); Serial.print(id); Serial.println(" was pressed only");
  }
}

AnalogButtons analogButtons(ANALOG_PIN, 30, &handleButtons);
Button b1 = Button(1, 1013,1014);
Button b2 = Button(2, 1002, 1002);
Button b3 = Button(3, 970, 971);
Button b4 = Button(4, 929, 933);
// Default hold duration is 1 second, lets make it 5 seconds for button5
Button b5 = Button(5, 860, 875, 5);

void setup()
{
  Serial.begin(9600);
  Serial.println("Testing your Analog buttons");
 
  analogButtons.addButton(b1);
  analogButtons.addButton(b2);
  analogButtons.addButton(b3);
  analogButtons.addButton(b4);
  analogButtons.addButton(b5); 
 }
 
void loop()

  // To check values when button are pressed
  analogButtons.checkButtons();
 
  // To configure the MAX/Min values for each
  // Button, uncomment this line, make sure you've called Serial.begin(9600);
  // Then in turn hold town each botton, noting the max/min values
  //AnalogButtons::configure(ANALOG_PIN); //delay(1000);
}
599  Using Arduino / Sensors / Re: Understanding 'Analog Buttons' on: February 16, 2011, 09:12:30 am
Please?
600  Using Arduino / Programming Questions / Open a library to better understand how it works on: February 16, 2011, 09:05:23 am
How to I open an H file, a library to see if it helps me understand how it works.  I'm trying to figure out how to use the  AnalogButtons library.
Pages: 1 ... 38 39 [40] 41 42 ... 44