Loading...
  Show Posts
Pages: 1 [2] 3 4 ... 14
16  Using Arduino / Sensors / Using push-button switches without pullup/pulldown resistors? on: April 11, 2013, 03:17:49 pm
Is it possible for me to use push-button switches without pullup/pulldown resistors? I may have made a mistake wiring push-button switches with pullup/pulldown resistors and the Pololu motor controllers don't work properly with switches. The motor controllers work without switches.

The motor controllers are shown in http://www.pololu.com/catalog/product/707
The switches are wired like the schematic shown in http://arduino.cc/en/Tutorial/Button

Code:
#include <Servo.h>
Servo servo01;
Servo servo02;
Servo servo03;
Servo servo04;
int InA1 = 22;
int InB1 = 23;
int PWM1 = 9;
int InA2 = 24;
int InB2 = 25;
int PWM2 = 10;
int InA3 = 26;
int InB3 = 27;
int PWM3 = 11;
int InA4 = 28;
int InB4 = 29;
int PWM4 = 12;
int switch01 = 38;
int switch02 = 39;
int switch03 = 40;
int switch04 = 41;
int switch05 = 42;
int switch06 = 43;
int switch07 = 44;
int switch08 = 45;
int switch09 = 46;
int switch10 = 47;
int switchstate01 = 0;
int switchstate02 = 0;
int switchstate03 = 0;
int switchstate04 = 0;
int switchstate05 = 0;
int switchstate06 = 0;
int switchstate07 = 0;
int switchstate08 = 0;
int switchstate09 = 0;
int switchstate10 = 0;
void setup()
{
  pinMode(InA1,OUTPUT);
  pinMode(InB1,OUTPUT);
  pinMode(PWM1,OUTPUT);
  pinMode(InA2,OUTPUT);
  pinMode(InB2,OUTPUT);
  pinMode(PWM2,OUTPUT);
  pinMode(InA3,OUTPUT);
  pinMode(InB3,OUTPUT);
  pinMode(PWM3,OUTPUT);
  pinMode(InA4,OUTPUT);
  pinMode(InB4,OUTPUT);
  pinMode(PWM4,OUTPUT);
  pinMode(switch01,INPUT);
  pinMode(switch02,INPUT);
  pinMode(switch03,INPUT);
  pinMode(switch04,INPUT);
  pinMode(switch05,INPUT);
  pinMode(switch06,INPUT);
  pinMode(switch07,INPUT);
  pinMode(switch08,INPUT);
  pinMode(switch09,INPUT);
  pinMode(switch10,INPUT);
  servo01.attach(5);
  servo02.attach(6);
  servo03.attach(7);
  servo04.attach(8);
  servo01.writeMicroseconds(1500);
  servo02.writeMicroseconds(1500);
  servo03.writeMicroseconds(1500);
  servo04.writeMicroseconds(1500);
  delay(1000);
}
void loop()
{
  switchstate01 = digitalRead(switch01);
  switchstate02 = digitalRead(switch02);
  switchstate03 = digitalRead(switch03);
  switchstate04 = digitalRead(switch04);
  switchstate05 = digitalRead(switch05);
  switchstate06 = digitalRead(switch06);
  switchstate07 = digitalRead(switch07);
  switchstate08 = digitalRead(switch08);
  switchstate09 = digitalRead(switch09);
  switchstate10 = digitalRead(switch10);
  if (switchstate01 == HIGH)
  {
    digitalWrite(InA1,HIGH);
    digitalWrite(InB1,LOW);
    analogWrite(PWM1,255);
  }
  if (switchstate02 == HIGH)
  {
    digitalWrite(InA1,LOW);
    digitalWrite(InB1,HIGH);
    analogWrite(PWM1,255);
  }
  if (switchstate01 == LOW && switchstate02 == LOW)
  {
    analogWrite(PWM1,0);
  }
  if (switchstate03 == HIGH)
  {
    digitalWrite(InA2,HIGH);
    digitalWrite(InB2,LOW);
    analogWrite(PWM2,255);
  }
  if (switchstate04 == HIGH)
  {
    digitalWrite(InA2,LOW);
    digitalWrite(InB2,HIGH);
    analogWrite(PWM2,255);
  }
  if (switchstate03 == LOW && switchstate04 == LOW)
  {
    analogWrite(PWM2,0);
  }
  if (switchstate05 == HIGH)
  {
    digitalWrite(InA3,HIGH);
    digitalWrite(InB3,LOW);
    analogWrite(PWM3,255);
  }
  if (switchstate06 == HIGH)
  {
    digitalWrite(InA3,LOW);
    digitalWrite(InB3,HIGH);
    analogWrite(PWM3,255);
  }
  if (switchstate05 == LOW && switchstate06 == LOW)
  {
    analogWrite(PWM3,0);
  }
  if (switchstate07 == HIGH)
  {
    digitalWrite(InA4,HIGH);
    digitalWrite(InB4,LOW);
    analogWrite(PWM4,255);
  }
  if (switchstate08 == HIGH)
  {
    digitalWrite(InA4,LOW);
    digitalWrite(InB4,HIGH);
    analogWrite(PWM4,255);
  }
  if (switchstate07 == LOW && switchstate08 == LOW)
  {
    analogWrite(PWM4,0);
  }
  if (switchstate09 == HIGH)
  {     
    servo01.writeMicroseconds(500);
    servo02.writeMicroseconds(2500);
    servo03.writeMicroseconds(500);
    servo04.writeMicroseconds(2500);
  }
  if (switchstate10 == HIGH)
  {     
    servo01.writeMicroseconds(2500);
    servo02.writeMicroseconds(500);
    servo03.writeMicroseconds(2500);
    servo04.writeMicroseconds(500);
  }
  if (switchstate09 == LOW && switchstate10 == LOW)
  {
    servo01.writeMicroseconds(1500);
    servo02.writeMicroseconds(1500);
    servo03.writeMicroseconds(1500);
    servo04.writeMicroseconds(1500);
  }
}
17  Using Arduino / Motors, Mechanics, and Power / Gear Motor Specs? on: April 07, 2013, 12:30:10 pm
If I want to buy some gear motors that have high torque and high speed to move a heavy (about 10-20 pounds) robot at about 5MPH, what gear motor specs should I look for?
18  Using Arduino / Motors, Mechanics, and Power / Re: Motor shaft sizes - do standard sizes exist? on: April 05, 2013, 07:59:54 pm
Are there shaft adapters for DC motors usually used in toys so that I can use rods that are larger than motor shafts?
19  Using Arduino / Motors, Mechanics, and Power / Re: Controling a 12 V Throttle body servo motor on: April 04, 2013, 08:05:37 pm
k3nshin, Please don't do anything to your car's electronic throttle. If you make a mistake and you have an accident that hurts or kills someone, you will be in a big trouble.
20  Using Arduino / Networking, Protocols, and Devices / Re: Seeedstudio XBee Shield V1.1 Help on: April 03, 2013, 02:49:07 pm
I have XBee S1 modules. The numbers at the top are STM-5, 940V-0, and 2411.
21  Using Arduino / Networking, Protocols, and Devices / Re: Seeedstudio XBee Shield V1.1 Help on: April 02, 2013, 02:51:09 pm
I already have XBee USB Adapter and XBee SIP Adapter made by Parallax. How do I configure the XBee modules so that they can talk with each other?
22  Using Arduino / Networking, Protocols, and Devices / Seeedstudio XBee Shield V1.1 Help on: April 02, 2013, 05:02:14 am
I bought two Seeedstudio XBEE Shields at Radio Shack and I can't get the XBee radios to "talk" with each other using the code on http://www.seeedstudio.com/wiki/index.php?title=XBee®_Shield.  Using the terminal monitor that came with Arduino IDE 1.04, I type some words on first terminal window and garbage appear on second terminal window. I try to type words on second terminal window but nothing appear on first terminal window. When I run the X-CTU program and try to test/query the modems, I get messages saying that they can't be found. How should the two toggle switches be set? Is there a tutorial on using the shields?
23  Using Arduino / Microcontrollers / Re: Arduino Mega2560 R3 pinouts photo on: March 30, 2013, 07:59:33 pm
I got confused by the photo of the Arduino Mega 2560 board with labeled pins. I think that the two pins at the top of the double header over pins 22 and 23 on the right side of the board are 5V pins. Are pins 23, 25, 27, and 29 digital pins? The labels on the photo confused me into thinking that pins 23, 25, 27, and 29 are 5V pins.
24  Using Arduino / Motors, Mechanics, and Power / Re: Trouble connecting Seeed Motor Shield without mounting on: March 29, 2013, 02:57:15 pm
Try connecting 5VDC and GND between Arduino and shield.
25  Using Arduino / Motors, Mechanics, and Power / Code for Seeed Studio Relay Shield V1.3? on: March 28, 2013, 04:28:18 am
I tried to download code for Seeed Studio Relay Shield V1.3 from Seeed Studio's website but the ZIP file is corrupted. How can I use the Relay Shield?
26  Using Arduino / Motors, Mechanics, and Power / Re: Motor Controllers for car seat motors? on: March 22, 2013, 04:48:22 am
Are there DIY circuits for motor controllers/drivers that accept at least 10A?
27  Using Arduino / Motors, Mechanics, and Power / Re: Motor Controllers for car seat motors? on: March 21, 2013, 02:46:30 pm
What about http://www.pololu.com/catalog/product/1377 ?
28  Using Arduino / Motors, Mechanics, and Power / Motor Controllers for car seat motors? on: March 21, 2013, 05:15:09 am
I ordered 4 car seat motors from http://www.sciplus.com/p/12-VDC-2500-RPM-AUTOMOTIVE-SEAT-MOTOR_49249
Now, I need motor controllers for them. They draw 1.3A at no load and 9.5A when stalled. They run at 2500 RPM. Which one is best and cheap?
29  Using Arduino / Sensors / Touch sensor suggestion? on: March 20, 2013, 02:48:54 pm
I am building a robot that is similar to the one in the image at http://www-robot.mes.titech.ac.jp/robot/walking/zerocarrier/zerocarrier_e.html
I need touch sensors with rollers or balls or wheels so that when the robot is rolling along the floor, the touch sensor's ball or roller or wheel is rolling along the floor. Any suggestions?
30  Using Arduino / Motors, Mechanics, and Power / Re: Best motor for sliding part of robot? on: March 18, 2013, 02:52:32 pm
I ordered four motors at http://www.sciplus.com/p/12-VDC-2500-RPM-AUTOMOTIVE-SEAT-MOTOR_49249 for $9.50 each. The motors accept 1/8" square shafts that Vex Robotics Kit has.
Pages: 1 [2] 3 4 ... 14