i have made a program to deduct value from stored account balance using keypad and send message to customers but there are many errors can somebody modify below program and send me correct program
my program is:
#include <EEPROM.h>
#include "SoftwareSerial.h"
#include<LiquidCrystal.h>
SoftwareSerial SIM900( 1 , 2 );
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd( 9, 8, 7, 6, 5, 4);
int addr = 0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello");
}
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[ROWS] = {
35, 33, 31
}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {
41, 39, 37
}; //connect to the column pinouts of the keypad
void loop() {
int val = analogRead(0) / 4;
void setup();
Serial.begin(9600);
EEPROM.write(addr,256 );
}
int aBAL = 1000;
int bBAL = 1500;
int cBAL = 2000;
int dBAL = 1500;
int eBAL =2000;
void setup();
begin (19200 );
serial. print ("AT+CMGF=1\r" );
serial. println("WAITNG FOR A customers numbers entry ......");
}
lcd.print("waiting for customers number");
SIM900. println ( "AT + CMGS = \"8433xxxx1\""); // CHANGE NUMBER TO BE MESSAGED HERE
delay(1000);
(keyid) = 0;
keyscan();
if (key_id == 1) {
lcd.println("THIS IS A");
aBAL = aBAL - (key-0);
if (aBAL >= (key-0))
delay(2000);
//}
SIM900. print ( "Hello, THANK YOU a, FOR USING OUR PRODUCTS YOUR BALANCE IS Rs.");
SIM900.print(aBAL);
}
else {
delay(2000);
//-----------
SIM900. print ( "Hello, THANK YOU a, FOR USING OUR GOODS BUT YOUR BALANCE IS TOO LOW PLEASE RECHARGE! ");
}
delay ( 1000);
SIM900. println (( char ) 26 );
delay ( 1000);
SIM900. println ();
digitalWrite(ledPin, LOW);
}
SIM900. println ( "AT + CMGS = \"8433xxxx2\""); // CHANGE NUMBER TO BE MESSAGED HERE
delay(1000);
else if (a == "2") {
lcdprint("THIS IS B");
bBAL = bBAL -(key-0);
if (bBAL >= (key-0))
delay(2000);
//}{
SIM900. print ( "Hello, THANK YOU b, FOR USING OUR PRODUCTS YOUR BALANCE IS Rs.");
SIM900.print(bBAL);
}
else {
delay(2000);
//-----------
SIM900. print ( "Hello, THANK YOU b, FOR USING OUR GOODS BUT YOUR BALANCE IS TOO LOW PLEASE RECHARGE! ");
}
delay ( 1000);
SIM900. println (( char ) 26 );
delay ( 1000);
SIM900. println ();
digitalWrite(ledPin, LOW);
}
SIM900. println ( "AT + CMGS = \"8433xxxxx3\""); // CHANGE NUMBER TO BE MESSAGED HERE
delay(1000);
else if (a == "3") {
lcdprint("THIS IS c");
bBAL = bBAL - (key-0);
if (bBAL >= (key-0))
delay(2000);
//}{
SIM900. print ( "Hello, THANK YOU c, FOR USING OUR PRODUCTS YOUR BALANCE IS Rs.");
SIM900.print(cBAL);
}
else {
delay(2000);
//-----------
SIM900. print ( "Hello, THANK YOU c, FOR USING OUR GOODS BUT YOUR BALANCE IS TOO LOW PLEASE RECHARGE! ");
}
delay ( 1000);
SIM900. println (( char ) 26 );
delay ( 1000);
SIM900. println ();
digitalWrite(ledPin, LOW);
SIM900. println ( "AT + CMGS = \"84336xxxx6\""); // CHANGE NUMBER TO BE MESSAGED HERE
delay(1000);
else if (a == "4") {
lcdprint("THIS IS d");
bBAL = bBAL - (key-0);
if (bBAL >= (key-0))
delay(2000);
//}{
SIM900. print ( "Hello, THANK YOU d, FOR USING OUR PRODUCTS YOUR BALANCE IS Rs.");
SIM900.print(dBAL);
}
else {
delay(2000);
//-----------
SIM900. print ( "Hello, THANK YOU d, FOR USING OUR GOODS BUT YOUR BALANCE IS TOO LOW PLEASE RECHARGE! ");
}
delay ( 1000);
SIM900. println (( char ) 26 );
delay ( 1000);
SIM900. println ();
digitalWrite(ledPin, LOW);
SIM900. println ( "AT + CMGS = \"84336xxx7\""); // CHANGE NUMBER TO BE MESSAGED HERE
delay(1000);
else if (a == "5") {
lcdprint("THIS IS e");
eBAL = eBAL - (key-0);
if (eBAL >= (key-0))
delay(2000);
//}{
SIM900. print ( "Hello, THANK YOU e, FOR USING OUR PRODUCTS YOUR BALANCE IS Rs.");
SIM900.print(eBAL);
}
else {
delay(2000);
//-----------
SIM900. print ( "Hello, THANK YOU e, FOR USING OUR GOODS BUT YOUR BALANCE IS TOO LOW PLEASE RECHARGE! ");
}
delay ( 1000);
SIM900. println (( char ) 26 );
delay ( 1000);
SIM900. println ();
digitalWrite(ledPin, LOW);
}
else { // WRONG number
delay(2000);
lcd.print("wrong number")
}
delay ( 1000);
SIM900. println (( char ) 26 );
delay ( 1000);
SIM900. println ();
digitalWrite(ledPin, LOW);
delay(5000);
}
}
Moderator edit: Code tags added. HTH