Go Down

Topic: Linksprite LCD, Motor Shield & Arduino UNO (Read 52 times) previous topic - next topic

justjay

Nov 18, 2014, 01:10 am Last Edit: Nov 18, 2014, 01:11 am by justjay
Hi All

Just joined the forum and I'm very new to both programming and circuitry, but wanted a bit of a project so here i am!

I've built a timelapse slider/rail and want to power it using an arduino uno and geared dc motor at the moment. That i have managed! Although, I'm only getting a very basic move - stop - move action (which is fine for now, although I'll need to time my shots!)

I picked up the following from a local Maplin store as they didn't have actual arduino LCD or motor shield in store. The motor shield works fine, as does the LCD...seperately.

http://linksprite.com/wiki/index.php5?title=16_X_2_LCD_Keypad_Shield_for_Arduino#Introduction

http://linksprite.com/wiki/index.php5?title=Motor_Shield#Introduction


I want to basically have the LCD buttons able to move and choose between different presets if you like, within the code. For example, the motor moves for 1 sec but stops for 30. Or moves for 3 sec and stops for 3 secs. However, I'm having a real struggle joining the two shields together then getting the code right. The motor shield doesn't allow mounting on top like others do, so I used a breadboard and jumped them across with the LCD on the UNO

The code I am using is:

#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
char text[]="ISO 100 Photography Timelapse Controller";

int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface
int speedpinA=9;//enable motor A
int pinI3=12;//define I3 interface
int pinI4=13;//define I4 interface
int speedpinB=10;//enable motor B
int spead =95;//define the spead of motor


void setup() 
{
// set up the LCD's number of columns and rows:
 lcd.begin(16,2);
 
 pinMode(pinI1,OUTPUT);
 pinMode(pinI2,OUTPUT);
 pinMode(speedpinA,OUTPUT);
 pinMode(pinI3,OUTPUT);
 pinMode(pinI4,OUTPUT);
 pinMode(speedpinB,OUTPUT);

}//--(end setup )---


void loop()   /
{
 unsigned int i=0;
 // set the cursor to (0,0):
 lcd.setCursor(0, 0);
 // print from 0 to 9:
 
 while(text!='\0'){
  lcd.print(text);
 
if(i>=14)
{
         lcd.command(0x18); //Scrolling text to Left
       }
  delay(50);
  i++;
  }
  // turn off automatic scrolling
 lcd.noAutoscroll();
 
 // clear screen for the next loop:
 lcd.clear();

analogWrite(speedpinA,spead);//input a simulation value to set the speed
    analogWrite(speedpinB,spead);
    digitalWrite(pinI4,HIGH);//turn DC Motor B move clockwise
    digitalWrite(pinI3,LOW);
    digitalWrite(pinI2,LOW);//turn DC Motor A move anticlockwise
    digitalWrite(pinI1,HIGH);

}//--(end main loop )---

void stop()//
{
    digitalWrite(speedpinA,LOW);// Unenble the pin, to stop the motor. this should be done to avid damaging the motor.
    digitalWrite(speedpinB,LOW);
    delay(2500);


}//--(end main loop )---


With this setup, both shields have power from a 9v to the UNO and 9v to the motor shield. the letters scroll but I can't get them to auto stop, and the motor won't run. There is a small LED on the motor shield blinking at me marked as IN1.

I apologise for the long first post, just struggling along and would really appreciate a few pointers!! :)

TIA

Jay

Go Up