Show Posts
Pages: 1 ... 45 46 [47] 48 49 ... 102
691  Using Arduino / Programming Questions / Re: Stepper with limit switches and push button to start on: February 11, 2014, 01:38:54 pm
Code:
if(button pressed);
       stage++;
Oops.
Oops indeed. Try this:
Code:
int stage = 1; //initial state

void setup(){
// your setup code here
}

void loop(){
switch (stage){
case 1:  //wait for button press to start
    if(button pressed)  stage++;
    break;
case 2:
    step motor 1 step  //loop runs very fast so movement will appear continuous
    if (endstop reached)  stage++;
   break;
case 3: //wait for button press to start
    if(button pressed)  stage++;
    break;
case 4: 
    step motor -1 step  //reverse direction...loop runs very fast so movement will appear continuous
    if (endstop reached)  stage++;
   break;
case 5:
   stage = 1;
   break;
}
}
692  Using Arduino / Programming Questions / Re: Looking for help on why randomly moving without any signal on: February 11, 2014, 01:25:44 pm
if add digitaRead where I think should go cannot compile? Ideas?
Balance your brackets:
Code:
    case 1: 
      //we loop here and do nothing UNLESS BUTTON IS PUSHED.
      if (digitalRead(buttonPin) == HIGH) stage ++;
      break;
case 2:..... 
693  Using Arduino / Programming Questions / Re: HELP! Can't find bugs in the code of my POV (mirrored display) on: February 10, 2014, 05:26:16 pm
Maybe, if you declared Pin12 as an input (as I already told you), you might be more successful.
hi sir! I already did that.
Where? It's not in the latest code you posted.
694  Using Arduino / Programming Questions / Re: Beginner Programmer: Error Messages and Peer Verification on: February 10, 2014, 05:06:44 pm
Note that !(buttonState==LOW) is the same as (buttonState==HIGH).
695  Using Arduino / Programming Questions / Re: Stepper with limit switches and push button to start on: February 10, 2014, 04:44:59 pm
State machine...
Code:
int stage = 1; //initial state

void setup(){
// your setup code here
}

void loop(){
switch (stage){
case 1:  //wait for button press to start
    if(button pressed);
       stage++;
    break;
case 2:
    step motor 1 step  //loop runs very fast so movement will appear continuous
    if (endstop reached);
       stage++;
   break;
case 3: //wait for button press to start
    if(button pressed);
       stage++;
    break;
case 4: 
    step motor -1 step  //reverse direction...loop runs very fast so movement will appear continuous
    if (endstop reached);
       stage++;
   break;
case 5:
   stage = 1;
   break;
}
}
696  Using Arduino / Programming Questions / Re: Looking for help on why randomly moving without any signal on: February 10, 2014, 04:15:48 pm
Try:
Code:
/**
 *  This sketch waits for the button to be pressed. The motor starts in forward direction,
 *  then every time the button is pressed the motor moves in the other direction.
 */
#include <StepperMotor.h>

// 4 pins of the stepper motor board
#define _PIN1 11
#define _PIN2 10
#define _PIN3 9
#define _PIN4 8

// define states that will have
//#define S_None     1
//#define S_Forward  2
//#define S_Stop     3
//#define S_Reverse  4
int stage =1; //set up initial state.
int buttonPin = 7;
StepperMotor stepper(_PIN1, _PIN2, _PIN3, _PIN4);

void setup()
{
  pinMode(13,OUTPUT);
  pinMode(_PIN1, OUTPUT);
  pinMode(_PIN2, OUTPUT);
  pinMode(_PIN3, OUTPUT);
  pinMode(_PIN4, OUTPUT);
  pinMode(buttonPin, INPUT);
}

void loop()
{
   switch(stage)
  {
    case 1:   
      //we just sit still here and doing nothing UNTIL BUTTON IS PUSHED.
      if(buttonPin == HIGH);
      stage ++;
      break;
    case 2:
      stepper.move(8192);  //stepper will stop after 8192 steps
      stage ++;
      break;
    case 3:
      if(buttonPin == HIGH); //wait for button to be pushed
      stage ++;
      break;
    case 4:
      stepper.move(-8192);   //stepper will stop after 8192 steps
      stage = 1;  //go back to start
      break;
   default:  //in case stage somehow gets outside 1 - 4
      stage = 1;  //go back to start
      break;
  }
}
697  Using Arduino / General Electronics / Re: Broken Wire in 5V Jack on: February 09, 2014, 04:49:30 pm
I am taking a microcontrollers course in college, and I have broken a bit of wire off in my 5V jack on my Uno while doing some homework.  Anyone have any tips on how to get this wire out?
Needle nosed tweezers or, failing that, a needle and patience.
698  Using Arduino / Programming Questions / Re: HELP! Can't find bugs in the code of my POV (mirrored display) on: February 09, 2014, 04:00:11 pm
sorry sir. I forgot to include my most updated code.


so, I've changed the settings in void loop. Most of the makers of arduino POV in the internet use this:
Code:
if(sensorReading == LOW)
{
then execute printing POV;
}
I've tried the sensorreading is equals to LOW . I've tried sensorreading is equals to HIGH as well. There are quite difference between that two. But I can't achieve what I want: "SCROLLING TEXT".
Maybe, if you declared Pin12 as an input (as I already told you), you might be more successful.
699  Using Arduino / Programming Questions / Re: temp min value 0 on: February 09, 2014, 03:43:12 pm
You might try actually assigning values to minTempC and maxTempC when you declare them. Try setting both to 149.0, to see what happens. Then, try setting both to -238.4 to see what happens. I'm sure that sooner or later, you'll stub your toe on a clue.
Absolutely  smiley
700  Using Arduino / Programming Questions / Re: Looking for help on why randomly moving without any signal on: February 09, 2014, 03:35:49 pm
Trust me I am not going to jump over anybody.  I am just grateful for another set of eyes to help me.  (Wife is a bit upset that blinds are moving all over) 

I guess I am under the impression that an interrupt is used to signal a change in the state of either pin 2 or 3.   Thus, I am needing to read the state change in pin 2.  So when I push the button it changes the state of pin 2 in my case thus utilizing an interrupt to read pin 2.
Look up 'finite state machine'.
Your blinds have four states:
1) blinds closed...Digitalread (button pin)
2) blinds opening
3) blinds open...Digitalread (button pin)
4) blinds closing
then back to state 1...

701  Using Arduino / Project Guidance / Re: Toy LED Gun on: February 09, 2014, 03:15:39 pm
wouldnt I run into the same problem with the state machines? can the code for the charging be changed to the firing code at any time during the charging code resulting in the charging code to stop?
Code:
Case 1:If(trigger pulled) increase charge a little each time around loop()
else change state to 2  //trigger has been released
break
Case  2:Fire!
No charge left...change state to 3
break
Case 3:if (trigger pulled) change state to 1 //waits for trigger to be pulled again.
break
 

Quote
What is the differences between a Finite State Machine and a State Machine?
None, except one less word.
Quote
and will they allow rising and falling edge detection?
Yes, but why would you need that if you're not using interupts?
702  Community / Website and Forum / Re: Problem with main Arduino website 8 Feb 2014 on: February 09, 2014, 12:19:40 am
I had the same problem a couple of days ago. Seems to have been cleared and I can now get onto the forum on both my desktop and laptop. Yay...
703  Using Arduino / General Electronics / Re: Any Good Switching P.S. For Arduinos In Industrial Environments?? or filters.. on: February 09, 2014, 12:10:43 am
The next one you make will have an external reset switch! smiley-wink

Hi Henry,

I was trying to avoid the ability for operators to easily reset any of these systems (though a key switch would be very nice but costly!).
Cheap keyswitch: 9 pin D plug . Cross wire some of the pins in the plug (eg 2 to 5, 3 to 8, 7 to 9) and put it in a cover. Fill with Araldite. A 9 pin D socket on each of your boxes wired to detect that the plug is in and only do a reset if the cross wiring is correct. You keep the plug in your possession so that nobody else can copy or use it.  You could even fit a momentary switch on the cover of the plug.
704  Using Arduino / Project Guidance / Re: Home phone system on: February 08, 2014, 11:27:41 pm
It might not need an arduino.

Perhaps some microphones, speakers, amplifiers and some switches...
Depends on how many rooms are to be connected. More than about 4 rooms and the switching and wiring gets mighty complicated.
Sub DECT phones in each room with one master in, say, the living room might be a better answer.
705  Using Arduino / Project Guidance / Re: Turn up the heat! on: February 08, 2014, 11:10:58 pm
program it to turn on in the morning as you like.
then have it turn on at the time you leave work.  run for a time, then shut off.  that way, if you are not home in time, it will not run all the time, but it will be warmer when you get home.
Something like a timeswitch...
Quote
I saw the note about long USB cables,  much prefer you use your phone while driving than reel in a long USB cable while driving.
Not what I was referring to, but you did make me smile smiley
Pages: 1 ... 45 46 [47] 48 49 ... 102