Show Posts
Pages: [1] 2 3 ... 228
1  Using Arduino / Motors, Mechanics, and Power / Re: Help in Stepper motor control with push button on: Today at 07:38:52 am
The problem is your section variable:
Code:
if(section==LOW){
    myStepper.step(100); // turningthe motor to 25 steps to get 45 degree rotaion
   section=true;

  }
Ignoring the fact that you're mixing up boolean values and LOW, the first time the button is pressed, section is false which happens to be zero, as is LOW, so the stepper steps and section is set to true (1). Next time the button is pressed, section isn't LOW any more and never will be again as you never change it, so the stepping portion isn't executed.

What is the section variable supposed to do?
2  Using Arduino / Project Guidance / Re: Maximum that arduino can handle. on: Today at 07:20:10 am
An arduino can do all that with ease. Depending on the specifics of your sensors and pumps you may have a lot of I/O lines to control, possibly more than a standalone Uno could manage. You could address this with shift registers or a larger arduino such as a Mega.
3  Using Arduino / Programming Questions / Re: Reading and writing to the same Arduino Pin on: Today at 07:13:11 am
You can digitalRead a pin you're also using for digitalWrite but generally the consensus is that you shouldn't need to. If you need to keep track of the state of the pin, you can use flags as mentioned above.

Often in a temperature control scenario though, you turn on a heater when it's too cold and turn it off when it's too hot. In a cold situation, if you set a pin high to turn on your heater on every iteration of loop, no harm done if it was high already so you really may not care whether the heater is currently on, just that it's too cold so you ensure that it is on.
4  Topics / Home Automation and Networked Objects / Re: HELP! Greenhouse contol concept problems PLEASE READ! on: Today at 06:30:40 am
What is driving this requirement?
Quote
a more advanced MC for controlling relays.

Have you considered using a Mega so you only need one MC?
5  Using Arduino / Programming Questions / Re: Understanding state machine example on: April 17, 2014, 03:47:31 pm
Thank you for the update!

How is adding time to NextAction problematic?  Is it the same risk of rollover?
Yes.
6  Using Arduino / Programming Questions / Re: Understanding state machine example on: April 17, 2014, 03:09:18 pm
The addition of time to NextAction is problematic too. Here's a refactor that should be better:
Code:
// States are named for ease of use
#define START   0 
#define SCANNING   1
#define RESULTS  2
#define RESET 3

// Timing variables
const int StartTime = 2500;
const int ScanTime = 1500;
const int RESULTSTime = 1500;
const int ResetTime = 2000;

int state=START;  // initial state
unsigned long StateStartTime=0L;
unsigned long StateDuration=0L;

void setup()
{
Serial.begin(9600);    // initialize serial communication for debugging
state=START;
StateStartTime=millis();
StateDuration=StartTime;
}

void loop()
{
if(millis()-StateStartTime > StateDuration)
  ChangeState(); 
 }

void ChangeState()  // Function declared outside of the main loop, for managing the state
{
StateStartTime=millis();
switch (state)
  {
  case START:
    Serial.println("case START");
    StateDuration=StartTime;
    state=SCANNING;
    break;
  case SCANNING:
    Serial.println("case SCANNING");
    StateDuration=ScanTime;
    state=RESULTS;
    break;
  case RESULTS:
    Serial.println("case RESULTS");
    StateDuration=RESULTSTime; 
    state=RESET;
    break;
  case RESET:
    Serial.println("case RESET"); 
    StateDuration=ResetTime;
    state=START;
    break;
  }
}
7  Using Arduino / Project Guidance / Re: Communication with smart meter using software serial 7E1 issue on: April 17, 2014, 11:56:27 am
Some of those characters likely won't display on an LCD and worse, may have special meanings to the LCD. Just read the serial data character by character into a variable. Keep another (boolean) variable that tells you whether the data you have should be sent to the LCD. Control the boolean by whether you've seen the paren characters I mentioned.
8  Using Arduino / Project Guidance / Re: Communication with smart meter using software serial 7E1 issue on: April 17, 2014, 11:38:39 am
To start with I'd just read data and throw it away until I saw a '('. Then send data to the LCD until I saw a ')'. That'll get you your numeric data, whatever it means.
9  Using Arduino / Project Guidance / Re: Count 18 lines and pause. on: April 17, 2014, 10:34:17 am
If you really only want 18 lines printed ever, put your for loop in setup. It sounds like there's more to it though so changing:
Code:
  for (x=0; x<19; x ++)
to
Code:
  for (; x<19; x ++)
Will get you closer.
10  Using Arduino / Programming Questions / Re: Arduino uno, ethernet shield, multiple ds18b20 and Xively on: April 17, 2014, 10:25:42 am
Assuming all the xively  stuff is working, what you need could likely be solved by changing this:
Code:
  int sensorValue = (sensors.getTempCByIndex(0));  //this is teh code from MBurton
  datastreams[0].setFloat(sensorValue);
  datastreams[1].setFloat(sensorValue);
to this:
Code:
  int sensorValue = (sensors.getTempCByIndex(0));  //this is teh code from MBurton
  datastreams[0].setFloat(sensorValue);
  sensorValue = (sensors.getTempCByIndex(1));  //this is teh code from MBurton
  datastreams[1].setFloat(sensorValue);
11  Using Arduino / Sensors / Re: Photo Interrupter Sensor Questions on: April 17, 2014, 07:36:58 am
What does the code look like for the failing digital version?
12  Using Arduino / Programming Questions / Re: Boat autopilot - PID not centralizing rudder. on: April 17, 2014, 07:21:55 am
Quote
Hopefully, I will get the wind vane a fair bit in front of the sail to make it undisturbed.

I've never seen such a thing on a sailboat, which makes me think that there's a good reason everyone puts their wind vane at the masthead. Your method is going to see slower wind speeds due to friction on the surface and will be subject to interference from spray.

On the other hand, it is true that traditional autohelms had a vane near deck level, but I suspect that that was a necessary compromise rather than a desired feature.

Edit: typo.
13  Using Arduino / Programming Questions / Re: Understanding state machine example on: April 17, 2014, 06:46:55 am
For some reason, I didn't bother making that code deal with rollover so if you're planning on running this for a long time (i.e. more than 49 days) it'll need a little restructuring. Search for millis and subtraction and you'll likely find one of the many discussions on the topic.
14  Using Arduino / Programming Questions / Re: TinyGPS++ - Failed checksum on: April 16, 2014, 01:29:04 pm
Quote
if i should post my code

Yes, you should  smiley-wink
15  Using Arduino / Project Guidance / Re: Problem in Serial Communication. on: April 16, 2014, 10:37:18 am
I just compiled it and sent it to a Mega using a Mac. Not very helpful, but it perhaps suggests that you have an issue with your environment.
Pages: [1] 2 3 ... 228