Show Posts
Pages: 1 ... 16 17 [18] 19 20 ... 49
256  Using Arduino / Programming Questions / Re: Similar functions, one is slower then the other!? on: April 24, 2013, 09:01:45 am
I don't see anything in the code that is obviously wrong, but I not an expert.. 

You could try to eliminate hardware problems.  Unplug one stepper and run the code with a stepper in the "stegOne" position.  If the motor works like it's expected to, then switch the motor to the "stegTwo" position.  This will tell you if there is a supply problem.

If that doesn't tell you anything, I would try to take out the NewPing library and code to see if it's a timer issue.  I can tell you that NewPing has screwed with me in the past with a the timers.
257  Community / Website and Forum / Re: What happened to labs.arduino.cc? on: April 23, 2013, 07:02:06 pm
Hopefully someone's working on it.  I haven't seen that before..
258  General Category / General Discussion / Re: Which Arduino is the best option on: April 23, 2013, 11:01:10 am
Hi Everyone

Im going to make an X-Y plotter by using 2 Stepper motors to control the X and Y axis, as well as a solenoid to move the pen up and down, ofcourse i would like to just input a sketch on a PC and let the XY plotter draw it. I wish to use an Arduino to control the power input to the 2 Stepper motors (turn them on and off) The Stepper motors that i am going to use have the following specifications...

Company: VEXTA (stepping motors)
Model: PXB44HZ-02AA-C8
DC 6V SR7 0.8 A  54354
2-phase 1.8degrees/step

the first question i have is...
1) My first worry is how does the Arduino power up the 2 stepper motors? To my knowledge I will need 2 PWM pins to power the 2 stepper motors and 1 for the solenoid, but will it provide power through the PWM pins, or does it produce a signal to turn on an EXTERNAL power supply which then powers the motor? (PLEASE correct me if i am wrong, i have been reading from nomber of sights and the information might be jumbled up in my head)

I think that the information is jumbled in your head.  The Arduino board will NOT power the steppers.  You will need a stepper driver or shield.  The easiest method is to have something like this: https://www.sparkfun.com/products/10267

Quote
2) I assume that i will somehow need to convert the CAD picture (or sketch) into Code, which i can then send to the Arduino to input the necessary power to the motors, and I assume that this is taken up by the Flash memory of the Arduino (agian Please correct if wrong), How much Flash memory do you think this will take  up?

You won't get much of the picture into RAM because there is very little RAM in an Arduino.  You will need some CAD program running on a PC to do the conversion.  I would suggest to Google Arduino CNC or something similar.

Quote
3) Am i missing something that is blatantly clear?

This is not a trivial project.  I suggest you do a lot of research.  If you are new to Arduino, I suggest you start with a simple task and work your way up.

Quote
I am currently using this page to compare the avialable arduinos....   https://www.sparkfun.com/arduino_guide   ....

I know you guys get this question 10 times a day but your help is greatly appreciated :p  .

An Arduino UNO will be a good starting point.  There are tons of examples and libraries.  I am also 99% sure that an UNO will be enough to accomplish what you are trying to do.
259  Using Arduino / Programming Questions / Re: What am I doing wrong? Sketch not recognising library... on: April 22, 2013, 08:04:31 pm
I got all the examples except for the ones with "NanodeMAC" in them. 
Quote
Although, I'm noticing with some of the others, when the ethershield library is included with a " ", instead of < >, it compliles properly.

The examples have quotes and it complies on my machine..

First thing I would do, take the Arduino program out of your downloads folder.  One day when you go and clean your computer of temporary files, that will be one of folders that gets deleted.  Move it to somewhere like C:\Programs Files\ (this is here most of your programs are kept anyway (if you're on a Windows PC)).
Second, right click in the address bar where you have installed the library and click "copy as text."  Paste it here.  This is mine: F:\Applications\Arduino\arduino-1.0.4\libraries\EtherShield

If that doesn't solve anything (which it probably won't), post your entire code in code tags.
260  Using Arduino / Microcontrollers / Re: Atmega programming on: April 22, 2013, 05:41:08 am
I believe if it's open source, then you can use it commercially.  You just can't sell the software that is programming the chips.
261  Using Arduino / Microcontrollers / Re: Atmega2560-16au Stand-alone (breadboard)? on: April 22, 2013, 05:36:28 am
Sure, if you can get the pins on the 2560 chip in the holes of the breadboard.  You are going to have to make a breakout or buy one..
262  Using Arduino / Programming Questions / Re: What am I doing wrong? Sketch not recognising library... on: April 22, 2013, 04:54:46 am
Did you restart the IDE after downloading the library?

He said he did in the first post.  Even stated he tried to restart the computer.

@Colomnmn
 You need to post ALL of the error codes.  Highlight the errors at the bottom of the IDE, copy them, click the # in the post reply editor and paste your the error between the code tags.
263  Using Arduino / General Electronics / Re: A Perfectly reasonable and good place to spend money.. on: April 21, 2013, 09:32:03 am
Thanks Doc, I've order some items and awaiting there arrival.

//LiNK
264  Using Arduino / Programming Questions / Re: Rookie trying to put Shrinkified Arduino to Sleep.... on: April 21, 2013, 09:04:26 am
I am thinking that it's the delays in your first sketch.  Look at the "Blink Without Delay" example in the IDE to get a method of using a sate machine.  This will get rid of the delays.

I don't think that Gammon's library is compatible with the ATTiny.
265  Using Arduino / Programming Questions / Re: How to make a loop within an IF statement (Bluetooth) on: April 21, 2013, 08:57:28 am
Why are you so ignorant and cocki on every post? do you think you're better than everyone? sitting behind a computer acting all smart, is this your way of making yourself look smart?. How about you leave this post go dig yourself a hole and sit in it then cover it up and stay there.

If Paul wouldn't have said the comments, someone else would have.  I think he was pretty calm in his replies..  And yes, he is the one member to listen to when it comes to the code. 
266  Community / Website and Forum / Re: Forum is popular and stuff gets lost on: April 20, 2013, 09:03:30 pm
I think Groove has a good point.  And I tend to agree with it. 
267  Using Arduino / Programming Questions / Re: Pin conflict - servos/easyVR on: April 20, 2013, 07:39:04 pm
The shaking could be from multiple things.  Like, interference, load on the servo, or a part of the code that is interfering with the timing of the signals.
268  Using Arduino / Programming Questions / Re: Pin conflict - servos/easyVR on: April 20, 2013, 05:40:22 pm
I am curious of how you have the servos powered.  You say that moving the signal wire to another pin, burnt the servo.  I don't see how that could happen unless you mixed the wires up from the supply.
269  Using Arduino / LEDs and Multiplexing / Re: Driving many Led's From Four Shift registers on: April 20, 2013, 11:59:02 am
Code:
/////////////////////////////////////////////////////
 //This is Sequence 3
 ////////////////////////////////////////////////////
void sequence3(){
  Serial.println("button 1");
  for (int i = 0; i < 4; i++)
  {
    bitSet(leds, i);
    updateShiftRegister3();
    delay(50);
    for (byte b = 0; b < 255; b++)
    {
      setBrightness(b);
      delay(20);
    }
    Serial.println(count);
    if(count>=3){
     Serial.println("Count =");
      Serial.print(count);
      leds = 0;
      //for (int i = 0; i < 4; i++)
  {
    bitSet(leds, -5);
    updateShiftRegister3();
    delay(50);
      setBrightness(255);
  }
      count = 0;
      break;
    }
    if (justpressed[0] && btnOn && (count >=3)) {
      Serial.println("Button 0 pressed again");
      count;
      leds = 0;
      setBrightness(255);
      break;
    }
  }
  //bitSet(leds,0);
  //delay(1000);
  sr1Colour = 2; //Set SR1 to red
 leds = 0;
   //switch_value = 0;
  setBrightness(255);
}
/////////////////////////////////////////////////////
 //This is Sequence 4
////////////////////////////////////////////////////
void sequence4(){
  Serial.println("button 1");
  for (int i = 0; i < 4; i++)
  {
    bitSet(leds, i);
    updateShiftRegister3();
    delay(50);
    for (byte b = 0; b < 255; b++)
    {
      setBrightness(b);
      delay(20);
    }
    Serial.println(count);
    if(count>=3){
     Serial.println("Count =");
      Serial.print(count);
      leds = 0;
      //for (int i = 0; i < 4; i++)
  {
    bitSet(leds, -5);
    updateShiftRegister4();
    delay(50);
      setBrightness(255);
  }
      count = 0;
      break;
    }
    if (justpressed[0] && btnOn && (count >=3)) {
      Serial.println("Button 0 pressed again");
      count;
      leds = 0;
      setBrightness(255);
      break;
    }
  }
  //bitSet(leds,0);
  //delay(1000);
  sr1Colour = 1; //Set SR1 to Green
 leds = 0;
   //switch_value = 0;
  setBrightness(255);
}
/////////////////////////////////////////////////////
 //This is Sequence 5
////////////////////////////////////////////////////
void sequence5(){
  Serial.println("button 1");
  for (int i = 0; i < 4; i++)
  {
    bitSet(leds, i);
    updateShiftRegister5();
    delay(50);
    for (byte b = 0; b < 255; b++)
    {
      setBrightness(b);
      delay(20);
    }
    Serial.println(count);
    if(count>=3){
     Serial.println("Count =");
      Serial.print(count);
      leds = 0;
      //for (int i = 0; i < 4; i++)
  {
    bitSet(leds, -5);
    updateShiftRegister5();
    delay(50);
      setBrightness(255);
  }
      count = 0;
      break;
    }
    if (justpressed[0] && btnOn && (count >=3)) {
      Serial.println("Button 0 pressed again");
      count;
      leds = 0;
      setBrightness(255);
      break;
    }
  }
  //bitSet(leds,0);
  //delay(1000);
 leds = 0;
   //switch_value = 0;
  setBrightness(255);
}
/////////////////////////////////////////////////////
 //This is Sequence 6
////////////////////////////////////////////////////
void sequence6(){
  Serial.println("button 1");
  for (int i = 0; i < 4; i++)
  {
    bitSet(leds, i);
    updateShiftRegister6();
    delay(50);
    for (byte b = 0; b < 255; b++)
    {
      setBrightness(b);
      delay(20);
    }
    Serial.println(count);
    if(count>=3){
     Serial.println("Count =");
      Serial.print(count);
      leds = 0;
      //for (int i = 0; i < 4; i++)
  {
    bitSet(leds, -5);
    updateShiftRegister6();
    delay(50);
      setBrightness(255);
  }
      count = 0;
      break;
    }
    if (justpressed[0] && btnOn && (count >=3)) {
      Serial.println("Button 0 pressed again");
      count;
      leds = 0;
      setBrightness(255);
      break;
    }
  }
  //bitSet(leds,0);
  //delay(1000);
 leds = 0;
   //switch_value = 0;
  setBrightness(255);
}
/////////////////////////////////////////////////////
 //This is Sequence 7
////////////////////////////////////////////////////
void sequence7(){
  Serial.println("button 1");
  for (int i = 0; i < 4; i++)
  {
    bitSet(leds, i);
    updateShiftRegister7();
    delay(50);
    for (byte b = 0; b < 255; b++)
    {
      setBrightness(b);
      delay(20);
    }
    Serial.println(count);
    if(count>=3){
     Serial.println("Count =");
      Serial.print(count);
      leds = 0;
      //for (int i = 0; i < 4; i++)
  {
    bitSet(leds, -5);
    updateShiftRegister7();
    delay(50);
      setBrightness(255);
  }
      count = 0;
      break;
    }
    if (justpressed[0] && btnOn && (count >=3)) {
      Serial.println("Button 0 pressed again");
      count;
      leds = 0;
      setBrightness(255);
      break;
    }
  }
  //bitSet(leds,0);
  //delay(1000);
 leds = 0;
   //switch_value = 0;
  setBrightness(255);
}
/////////////////////////////////////////////////////
 //This is Sequence 8
////////////////////////////////////////////////////
void sequence8(){
  Serial.println("button 1");
  for (int i = 0; i < 4; i++)
  {
    bitSet(leds, i);
    updateShiftRegister8();
    delay(50);
    for (byte b = 0; b < 255; b++)
    {
      setBrightness(b);
      delay(20);
    }
    Serial.println(count);
    if(count>=3){
     Serial.println("Count =");
      Serial.print(count);
      leds = 0;
      //for (int i = 0; i < 4; i++)
  {
    bitSet(leds, -5);
    updateShiftRegister8();
    delay(50);
      setBrightness(255);
  }
      count = 0;
      break;
    }
    if (justpressed[0] && btnOn && (count >=3)) {
      Serial.println("Button 0 pressed again");
      count;
      leds = 0;
      setBrightness(255);
      break;
    }
  }
  //bitSet(leds,0);
  //delay(1000);
 leds = 0;
   //switch_value = 0;
  setBrightness(255);
}
/////////////////////////////////////////////////////
 //This is Final Sequence 1
////////////////////////////////////////////////////
 void sequenceFinal1(){
   sequence5();
   sequence7();
 }
/////////////////////////////////////////////////////
 //This is Final Sequence 2
////////////////////////////////////////////////////
void sequenceFinal2(){
   sequence5();
   sequence8();
 }
/////////////////////////////////////////////////////
 //This is Final Sequence 3
////////////////////////////////////////////////////
void sequenceFinal3(){
   sequence6();
   sequence7();
 }
/////////////////////////////////////////////////////
 //This is Final Sequence 4
////////////////////////////////////////////////////
void sequenceFinal4(){
   sequence6();
   sequence8();
 }
270  Using Arduino / LEDs and Multiplexing / Re: Driving many Led's From Four Shift registers on: April 20, 2013, 11:58:16 am
Maybe PaulS or someone can go through it.  There's stuff that I don't even understand..

Had split it between 2 posts.  9500 character limit needs to be raised since we have to post code.

Code:
#include <Button.h>

int latchPin = 5;
int clockPin = 6;
int dataPin = 4;
int outputEnablePin = 3;
int ledPin = 10;
//Button trigger = Button(2,LOW);
int sr1Colour = 0;  // Set for ShiftReg1 as 0 = off, 1 = green, 2 = red
int sr2Colour = 0;

byte leds = 0;
byte button[] = {8, 9};
byte switch_value = 0;
boolean btnOn = false;
int count = 0;

#define NUMBUTTONS sizeof(button)
byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];

void setup() {
  setBrightness(0);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
  pinMode(outputEnablePin, OUTPUT);
  //pinMode(2,INPUT); //Trigger switch sits on pin 2
  Serial.begin(9600);
  Serial.println("Welcome");
  byte i;
  
   for (i=0; i< NUMBUTTONS; i++) {
    pinMode(button[i], INPUT);
    digitalWrite(button[i], HIGH);
  }
    //Timer2 Overflow Interrupt Enable
  TIMSK2 |= 1<<TOIE2;
}
//byte pressCount1 = 0;
SIGNAL(TIMER2_OVF_vect) {
  check_switches();
}

void check_switches()
{
  static byte previousstate[NUMBUTTONS];
  static byte currentstate[NUMBUTTONS];
  byte index;

  for (index = 0; index < NUMBUTTONS; index++) {
    currentstate[index] = digitalRead(button[index]);   // read the button
    /*    
    Serial.print(index, DEC);
    Serial.print(": cstate=");
    Serial.print(currentstate[index], DEC);
    Serial.print(", pstate=");
    Serial.print(previousstate[index], DEC);
    Serial.print(", press=");
    */
    
    if (currentstate[index] == previousstate[index]) {
      if ((pressed[index] == LOW) && (currentstate[index] == LOW)) {
          // just pressed
          justpressed[index] = 1;
          count = count+1;
          //switch_value = switch_value + 1;

      }
      else if ((pressed[index] == HIGH) && (currentstate[index] == HIGH)) {
          // just released
          justreleased[index] = 1;
      }
      pressed[index] = !currentstate[index];  // remember, digital HIGH means NOT pressed
    }
    //Serial.println(pressed[index], DEC);
    previousstate[index] = currentstate[index];   // keep a running tally of the buttons
  }
}


void loop() {
 /////////////////////////////////////////////////////
 //This is Button 1 Set Press
 /////////////////////////////////////////////////////
  
  if(justpressed[0] && btnOn)
  {
    count;
    sequence2();
    justpressed[0] = 0;
    btnOn = false;
  }  
  if(justpressed[0]) {
    Serial.println("Button 0 pressed");
    btnOn = true;
    count;
    justpressed[0] = 0;
    sequence1();
   }
//  /////////////////////////////////////////////////////
// //This is Button 2 Set Press
// /////////////////////////////////////////////////////
if(justpressed[1] && btnOn)
  {
    count;
    sequence1();
    justpressed[1] = 0;
    btnOn = false;
  }  
  if(justpressed[1]) {
    Serial.println("Button 1 pressed");
    btnOn = true;
    count;
    justpressed[1] = 0;
    sequence2();
   }
//  /////////////////////////////////////////////////////
// //Run final Sequence1
// /////////////////////////////////////////////////////

if (sr1Colour ==1 && sr2Colour==1){
  sequenceFinal1();
  ledPin = HIGH;
}
//  /////////////////////////////////////////////////////
// //Run final Sequence2
// /////////////////////////////////////////////////////

if (sr1Colour ==1 && sr2Colour==2){
  sequenceFinal2();
  ledPin = HIGH;
}
//  /////////////////////////////////////////////////////
// //Run final Sequence3
// /////////////////////////////////////////////////////

if (sr1Colour ==1 && sr2Colour==1){
  sequenceFinal3();
  ledPin = HIGH;
}
//  /////////////////////////////////////////////////////
// //Run final Sequence4
// /////////////////////////////////////////////////////

if (sr1Colour ==1 && sr2Colour==2){
  sequenceFinal4();
  ledPin = HIGH;
}
}
/////////////////////////////////////////////////////
 //This is updateShiftRegister
 ////////////////////////////////////////////////////
void updateShiftRegister()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);// Change the start LED to 1
   digitalWrite(latchPin, HIGH);
}
/////////////////////////////////////////////////////
 //This is updateShiftRegister2
 ////////////////////////////////////////////////////
void updateShiftRegister2()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, MSBFIRST, leds);// Change the start LED to 8
   digitalWrite(latchPin, HIGH);
}
/////////////////////////////////////////////////////
 //This is updateShiftRegister3
 ////////////////////////////////////////////////////
void updateShiftRegister3()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);// Change the start LED to 1
   digitalWrite(latchPin, HIGH);
}
/////////////////////////////////////////////////////
 //This is updateShiftRegister4
 ////////////////////////////////////////////////////
void updateShiftRegister4()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, MSBFIRST, leds);// Change the start LED to 8
   digitalWrite(latchPin, HIGH);
}
/////////////////////////////////////////////////////
 //This is updateShiftRegister5
 ////////////////////////////////////////////////////
void updateShiftRegister5()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);// Change the start LED to 8
   digitalWrite(latchPin, HIGH);
}
/////////////////////////////////////////////////////
 //This is updateShiftRegister6
 ////////////////////////////////////////////////////
void updateShiftRegister6()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, MSBFIRST, leds);// Change the start LED to 8
   digitalWrite(latchPin, HIGH);
}
/////////////////////////////////////////////////////
 //This is updateShiftRegister7
 ////////////////////////////////////////////////////
void updateShiftRegister7()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);// Change the start LED to 8
   digitalWrite(latchPin, HIGH);
}
/////////////////////////////////////////////////////
 //This is updateShiftRegister8
 ////////////////////////////////////////////////////
void updateShiftRegister8()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, MSBFIRST, leds);// Change the start LED to 8
   digitalWrite(latchPin, HIGH);
}
/////////////////////////////////////////////////////
 //This is setBrightness
 ////////////////////////////////////////////////////
void setBrightness(byte brightness) // 0 to 255
{
  analogWrite(outputEnablePin, 255-brightness);
}
/////////////////////////////////////////////////////
 //This is Sequence 1
 ////////////////////////////////////////////////////
void sequence1(){
  Serial.println("button 1");
  for (int i = 0; i < 4; i++)
  {
    bitSet(leds, i);
    updateShiftRegister();
    delay(50);
    for (byte b = 0; b < 255; b++)
    {
      setBrightness(b);
      delay(20);
    }
    Serial.println(count);
    if(count>=3){
     Serial.println("Count =");
      Serial.print(count);
      leds = 0;
      //for (int i = 0; i < 4; i++)
  {
    bitSet(leds, -5);
    updateShiftRegister();
    delay(50);
      setBrightness(255);
  }
      count = 0;
      break;
    }
    if (justpressed[0] && btnOn && (count >=3)) {
      Serial.println("Button 0 pressed again");
      count;
      leds = 0;
      setBrightness(255);
      break;
    }
  }
  //bitSet(leds,0);
  //delay(1000);
   sr1Colour = 1; //Set SR1 to green
 leds = 0;
   //switch_value = 0;
  setBrightness(255);
}
/////////////////////////////////////////////////////
 //This is Sequence 2
 ////////////////////////////////////////////////////
void sequence2(){
  Serial.println("button 2");
  for (int i = 0; i < 4; i++)
  {
    bitSet(leds, i);
    updateShiftRegister2();
    delay(50);
    for (byte b = 0; b < 255; b++)
    {
      setBrightness(b);
      delay(20);
    }
    Serial.println(count);
    if(count>=3)
    {
      Serial.println("Count =");
      Serial.print(count);
      leds = 0;
      //for (int i = 0; i < 4; i++)
  {
    bitSet(leds, -5);
    updateShiftRegister2();
    delay(50);
      setBrightness(255);
  }
      count = 0;
      break;
    }
    if (justpressed[1] && btnOn && (count >=3)) {
      leds = 0;
      break;
    }
  }
  //bitSet(leds,0);
  //delay(1000);
   sr1Colour = 2; //Set SR1 to red
  
  leds = 0;
   //switch_value = 0;
  setBrightness(255);
}
Pages: 1 ... 16 17 [18] 19 20 ... 49