// experiment 2 interfacing with motor , buzzer and display
#include <LiquidCrystal.h>
// pins connected
#define Ap 10 // A+ line
#define Am 11 // A- line
#define Bp 9 // .
#define Bm 8 // .
LiquidCrystal lcd(7,6,5,4,3,2);
void setup() {
// set output
pinMode(Ap,OUTPUT); pinMode(Am,OUTPUT);
pinMode(Bp,OUTPUT); pinMode(Bm,OUTPUT);
tone(13, 262, 250); // Plays 262Hz tone for 0.250 seconds
lcd.begin(16, 2);
// you can now interact with the LCD, e.g.:
lcd.print("Hello World!");
}
int I = 0 ;
void loop() {
// This is Wave Fullstep motion - only one coil energized at a time
if ( I++ <25 ) { // stop after 25*4 steps (=100) - quarter turn with gearRatio "2:1"
delay(10);
digitalWrite(Bm,LOW) ; digitalWrite(Ap,HIGH);
delay(10);
digitalWrite(Ap,LOW) ; digitalWrite(Bp,HIGH);
delay(10);
digitalWrite(Bp,LOW) ; digitalWrite(Am,HIGH);
delay(10);
digitalWrite(Am,LOW) ; digitalWrite(Bm,HIGH);
} else while(1);
}