Show Posts
Pages: 1 ... 45 46 [47] 48 49 ... 102
691  Using Arduino / Programming Questions / Re: 3 separate programm timers on: February 13, 2014, 11:14:05 am
In the IDE go File > Examples > 02.Digital > Blinkwithoutdelay. Read and understand. Use different variables for each process you need to time.
692  Using Arduino / Project Guidance / Re: Arduino uno for car ignition key help on: February 13, 2014, 11:05:00 am
Which make car? Which model? Which year?
A picture of the key might also help.
693  Using Arduino / Project Guidance / Re: Guns and Lasers on: February 13, 2014, 10:59:35 am
At 300Mtrs/sec you've only got about 20 microseconds (max) to detect a 6mm pellet. You'll have to detect in both the X and Y axes within those 20 microseconds to get an accurate position. Your code, even using interupts, will have to be minimal to allow two reads in that short space of time.
694  Using Arduino / Programming Questions / Re: Stepper with limit switches and push button to start on: February 12, 2014, 01:18:09 pm
Something to think about.
If the motor is stopped in the middle, in which direction should it start again?
1) continue in the same direction,
2) go in the opposite direction,
3) go to the nearest end,
4) go to the furthest end?
695  Using Arduino / Programming Questions / Re: Stepper with limit switches and push button to start on: February 11, 2014, 03:12:57 pm
So do I just call functions in each stage then?
Yes, you can do that.

The issue I am having right now is have the motor stopped at the start.[/quote]
Post your revised code.
696  Using Arduino / Programming Questions / Re: Looking for help on why randomly moving without any signal on: February 11, 2014, 03:07:48 pm
This code does verify & load fine.  But not giving desired results at all....
if D7 is connected to ground to start motor stays stopped. If pull D7 from ground starts counter clock.   If leave D7 open just keeps going full 2 turns then bounces back clock wise w turns then back counter....

If D7 is reconnected to ground motor will finish direction it is going the two full rotations then stop.
If D7 is removed again from ground and then reconnected to ground will go full two rotations then stop
If at any time I connect D7 to positive, the motor will just continue to go full 2 turns each way bouncing back and fourth infinitely. 

Basically briefly breaking D7 Ground connection reset the unit

Then change both   if (digitalRead(buttonPin) == HIGH) stage ++; to   if (digitalRead(buttonPin) == LOW) stage ++;
Connecting a pin (via a switch) to ground pulls it LOW.
697  Using Arduino / Programming Questions / Re: Looking for help on why randomly moving without any signal on: February 11, 2014, 01:47:29 pm
I bit, I am only on a Samsung 500t  Very underpowered .

Is that where digitalread should even go?
YOU'RE STILL NOT BALANCING YOUR BRACKETS!
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 (digitalRead(buttonPin) == HIGH) {// REMOVE THIS CURLY BRACKET
      stage ++;
      break;
    case 2:
      stepper.move(8192);  //stepper will stop after 8192 steps
      stage ++;
      break;
    case 3:
      if (digitalRead(buttonPin) == HIGH) {// REMOVE THIS CURLY BRACKET

//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;
  }
  }}
}
698  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;
}
}
699  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:..... 
700  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.
701  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).
702  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;
}
}
703  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;
  }
}
704  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.
705  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.
Pages: 1 ... 45 46 [47] 48 49 ... 102