this is link for my motor shield:
this is link for my lcd keypad shield:
http://www.dfrobot.com/wiki/index.php?title=Arduino_LCD_KeyPad_Shield_(SKU:_DFR0009)
this is link for my stepper motor:
this is link for my Enhanced 2A Stepper Motor Driver:
actually i don't no how to connect Enhanced 2A Stepper Motor Driver with my arduino rev3, what i konw is Enhanced 2A Stepper can connect with arduino rev3 by using UART. below is my sample programming by using dc geared motor.
this is my sample of programming:
#include <LiquidCrystal.h>
/*
The circuit:
- LCD RS pin to digital pin 8
- LCD Enable pin to digital pin 9
- LCD D4 pin to digital pin 4
- LCD D5 pin to digital pin 5
- LCD D6 pin to digital pin 6
- LCD D7 pin to digital pin 7
- LCD R/W pin to ground
*/
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
//Keypad Button Numbering
#define RG 0
#define UP 1
#define DW 2
#define LF 3
#define SEL 4
//constant variable
const int mtr1_In1 = 5;
const int mtr1_In2 = 6;
const int mtr2_In1 = 4;
const int mtr2_In2 = 7;
int analogPin = A0;
int adc_key_old;
int adc_key_in;
int NUM_KEYS = 5;
int adc_key_val[5] ={30, 150, 360, 535, 760};
/*******************************************************************************
- PRIVATE FUNCTION: setup()
- PARAMETERS:
- ~ void
- RETURN:
- ~ void
- DESCRIPTIONS:
- Define of I/O pin as Input or Output
*******************************************************************************/
// The setup() method runs once, when the sketch starts
void setup ()
{
//Set the mode for each digital pins whether input or output
pinMode(mtr1_In1, OUTPUT);
pinMode(mtr1_In2, OUTPUT);
pinMode(mtr2_In1, OUTPUT);
pinMode(mtr2_In2, OUTPUT);
lcd.begin(16, 2); // set the lcd dimension
lcd.clear(); // LCD screen clear
lcd.setCursor(0,0);
adc_key_old = analogRead(analogPin); // store the unpress key value
}
/*******************************************************************************
- PRIVATE FUNCTION: loop()
- PARAMETERS:
- ~ void
- RETURN:
- ~ void
- DESCRIPTIONS:
- Non-Stop looping
*******************************************************************************/
void loop()
{
adc_key_in = analogRead(analogPin); // read ADC value
adc_key_in = get_key(adc_key_in);
lcd.clear();
if(adc_key_in == UP) // Check whether Up button pressed
{ // Move forward
analogWrite(mtr1_In1, 220);
digitalWrite(mtr1_In2, HIGH);
analogWrite(mtr2_In1, 220);
digitalWrite(mtr2_In2, LOW);
lcd.setCursor(0, 1);
lcd.print("Move Forward");
delay(200);
}
else if(adc_key_in == DW) // Check whether Down button pressed
{ // Move backward
analogWrite(mtr1_In1, 220);
digitalWrite(mtr1_In2, LOW);
analogWrite(mtr2_In1, 220);
digitalWrite(mtr2_In2, HIGH);
lcd.setCursor(0, 1);
lcd.print("Move Backward");
delay(200);
}
else if(adc_key_in == LF) // Check whether Left button pressed
{ // Rotate to left
analogWrite(mtr1_In1, 150);
digitalWrite(mtr1_In2, LOW);
analogWrite(mtr2_In1, 220);
digitalWrite(mtr2_In2, LOW);
lcd.setCursor(0, 1);
lcd.print("Rotate to Left");
delay(200);
}
else if(adc_key_in == RG) // Check whether Right button pressed
{ // Rotate to right
analogWrite(mtr1_In1, 220);
digitalWrite(mtr1_In2, HIGH);
analogWrite(mtr2_In1, 150);
digitalWrite(mtr2_In2, HIGH);
lcd.setCursor(0, 1);
lcd.print("Rotate to Right");
delay(200);
}
else
{ // Display button navigation for each movement
lcd.setCursor(0,0);
lcd.print("UP=FW DW=BW");
lcd.setCursor(0,1);
lcd.print("LF=LF RG=RG");
delay(200);
analogWrite(mtr1_In1, 0);
analogWrite(mtr2_In1, 0);
}
}
/*******************************************************************************
- PRIVATE FUNCTION: get_key
- PARAMETERS:
- ~ integer
- RETURN:
- ~ unsigned int input
- DESCRIPTIONS:
- convert the ADC value to number between 0 to 4
*******************************************************************************/
int get_key(unsigned int input)
{
int k;
for (k = 0; k < NUM_KEYS; k++)
{
if (input < adc_key_val[k])
{
return k;
}
}
if (k >= NUM_KEYS)
k = -1; // No valid key pressed
return k;
}
but it doesnt work.... =(