i trying make vending machine standard coin acceptor , 2 momentary push buttons, stepper motors , lcd.
details:
arduino mega 2560 r3
hd44780 1602 lcd character display 16 x 2 (with 10k potentiometer)
ch 926 coin acceptor
2 pin momentary push buttons x2
28byj-48 stepper motors x2
the problem having once arduino reads pulses , if function fulfilled, lcd flickers (the writing flickers). seems though pulses interfering lcd, i'm not sure how go fixing issue.
i new arduinos , code reflect that, if please explain or give examples in newbie terms, appreciated.
thanks
details:
arduino mega 2560 r3
hd44780 1602 lcd character display 16 x 2 (with 10k potentiometer)
ch 926 coin acceptor
2 pin momentary push buttons x2
28byj-48 stepper motors x2
the problem having once arduino reads pulses , if function fulfilled, lcd flickers (the writing flickers). seems though pulses interfering lcd, i'm not sure how go fixing issue.
code: [select]
#include <liquidcrystal.h>
#include <stepperak.h>
#define gearratio 64
const byte stepsperrevolution = 2048;
const byte stepsperrevolution2 = 2048;
const byte coinint = 0; //this pin 2 on arduino
const byte ledpin = 13;
const byte switchpin = 30;
const byte switchpin2 = 31;
byte resetpin = 14;
stepper mystepper (stepsperrevolution, 46,47,48,49);
stepper mystepper2 (stepsperrevolution2, 50,51,52,53);
volatile float coinsvalue = 0.00;
byte coinschange = 0;
liquidcrystal lcd(7,8,9,10,11,12);
void setup()
{
digitalwrite (resetpin, high);
serial.begin(2400);
pinmode(ledpin, output);
attachinterrupt(coinint, coininserted, rising);
mystepper.setspeed(0.15*gearratio);
mystepper2.setspeed(0.15*gearratio);
pinmode (switchpin, input_pullup);
pinmode (switchpin2, input_pullup);
pinmode (resetpin, output);
lcd.begin(16,2);
lcd.clear();
lcd.print("please insert");
lcd.setcursor(0,1);
lcd.print("coins...");
}
void(* resetfunc) (void) = 0;
void coininserted()
{
coinsvalue = coinsvalue + 0.20; //1 dollar set 5 pulses, , 2 10, 1 pulse means adding 20 cents
coinschange = 1;
}
void loop()
{
if(coinschange == 1)
{
serial.print("amount: $");
serial.println(coinsvalue);
lcd.clear();
lcd.print("$ ");
lcd.print(coinsvalue);
if(coinsvalue >= 2)
{
// stepper motor code supposed go here, there needs 2 motor codes, 1 each switch & @ end, coinsvalue needs reset
lcd.clear();
lcd.print("press button..");
if(digitalread (switchpin) == low)
{
serial.println ("button 1 pressed");
digitalwrite(ledpin, high);
lcd.clear();
lcd.print("vending!");
delay (500);
serial.println("vend motor 1");
motorcode1();
delay (500);
coinsvalue = 0;
digitalwrite(ledpin, low);
coinschange = 0;
lcd.clear();
lcd.print("thank you!");
delay(2000);
lcd.clear();
digitalwrite (resetpin, low);
resetfunc();
}
if(digitalread (switchpin2) == low)
{
serial.println ("button 2 pressed");
digitalwrite(ledpin, high);
delay (500);
lcd.clear();
lcd.print("vending!");
serial.println("vend motor 2");
motorcode2();
delay (500);
coinsvalue = 0;
digitalwrite(ledpin, low);
coinschange = 0;
lcd.clear();
lcd.print("thank you!");
delay(2000);
lcd.clear();
digitalwrite (resetpin, low);
resetfunc();
}
}
}
}
void motorcode1()
{
mystepper.step(stepsperrevolution);
}
void motorcode2()
{
mystepper2.step(stepsperrevolution2);
}
i new arduinos , code reflect that, if please explain or give examples in newbie terms, appreciated.
thanks
hi , welcome.
can tell more flickering, see ?
what mean pulses ?
do mean button being pushed ?
or mean pulse coin acceptor ?
your code control motors isn't finished yet, have controller(s) connected ?
can tell more flickering, see ?
what mean pulses ?
do mean button being pushed ?
or mean pulse coin acceptor ?
your code control motors isn't finished yet, have controller(s) connected ?
Arduino Forum > Using Arduino > Displays > LCD flickers with pulses
arduino
Comments
Post a Comment