Sunday, May 3, 2015
Saturday, January 17, 2015
Friday, January 16, 2015
Monday, January 5, 2015
Thursday, December 25, 2014
Monday, September 22, 2014
Friday, September 19, 2014
Wednesday, September 3, 2014
Tuesday, August 19, 2014
Friday, August 8, 2014
Wednesday, August 6, 2014
Monday, August 4, 2014
Wednesday, July 30, 2014
Tuesday, July 29, 2014
Monday, July 28, 2014
Sunday, July 27, 2014
Thursday, December 26, 2013
Arduinostepperproject1
/*
AdaFruit motor shield, 12v. motor, 2 buttons.
Motor moves counterclockwise when button1 is pressed (HIGH).
Motor moves clockwise when button2 is pressed.
If a button is not pressed motor is released.
*/
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_StepperMotor *myMotor1 = AFMS.getStepper(200, 1);
const int buttonPin1 = 2; // the number of the pushbutton pin
const int buttonPin2 = 3;
// variables will change:
int buttonState1 = 0; // variable for reading the pushbutton status
int buttonState2 = 0;
void setup() {
AFMS.begin(1600); // OR with a different frequency, say 1KHz
myMotor1->setSpeed(800);
pinMode(buttonPin1, INPUT); // initialize the pushbutton pin as an input:
}
void loop()
{
buttonState1 = digitalRead(buttonPin1); // read the state of the pushbutton value:
buttonState2 = digitalRead(buttonPin2);
// check if the pushbutton is pressed.
if (buttonState1 != 0) // if it is, the buttonState is HIGH:
{
myMotor1->step(HIGH, FORWARD, DOUBLE);//counterclockwise
}
if (buttonState2 != 0) {
myMotor1->step(HIGH, BACKWARD, DOUBLE);//clockwise
}
else( myMotor1-> release());
}
Subscribe to:
Comments
(
Atom
)
















