
13-03-2013, 01:56
|
 |
 |
Registered User
AKA: Cory McBride
 FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
|
|
Join Date: May 2002
Rookie Year: 2001
Location: Redwood City, CA
Posts: 6,814
|
|
|
Re: arduino victor 884 and a cim
Quote:
Originally Posted by Crawler
why am i so incompetent at stuff like this, i just dont see how it all adds up, could you post a few lines of example code? just enough to make it run in 1 direction and i can probably figure it out.
Thanks,
Nick
|
Here is the code from the project I referenced:
#include <Servo.h>
Servo myservo1;
Servo myservo2;
void setup()
{
pinMode(10, OUTPUT); //motor
pinMode(11, OUTPUT); //solenoid
pinMode(12, INPUT); //Switch 0
pinMode(8,INPUT);//Switch 1
digitalWrite(12, HIGH); // turn on pullup resistor
digitalWrite(8,HIGH); //turn on pullup resistor
myservo1.attach(10); //motor
myservo2.attach(11); //solenoid
Serial.begin(9600);
}
void loop()
{
int button_0=digitalRead(12);
int button_1=digitalRead(8);
while ((button_0==0) && (analogRead(A0)!=0)) //while button 0 is pressed and A0 is not equal to 0
{
myservo1.write(0); //close door
}
while ((button_1==0) && (analogRead(A1)!=0)) //while button 1 is pressed and A1 is not equal to 0
{
myservo2.write(180); //activate solenoid
myservo1.write(112); //open door
}
myservo1.write(92); //turn off motor
myservo2.write(92); //turn off solenoid
}
__________________
2001-2004: Team 100
2006-Present: Team 254
|