Arduino ByVac BV4218 Complete Library

Well, after quite a bit of hair pulling the lcd and keypad of the ByVac BV4218 I2C module now works. Below are the directions to get the keypad and lcd working.

Download The Library

If you'd like to donate for the time and hardware I've invested into the project feel free :-).

 

 

 

Basic Setup:

#include <ByVacLCD.h>
#include <Wire.h>

int keypushed;
int keymap;
int addr;

ByVacLCD lcd = ByVacLCD(0x21,4,20);

void setup()
{
  Serial.begin(9600);
  lcd.init();
}

void loop()
{
  lcd.clear();
  lcd.print("Hello");
  lcd.setCursor(1,0);
  lcd.print("set cursor");
  lcd.setCursor(2,0);
  lcd.print("Key Pushed: ");
  lcd.print(lcd.get_key());
  delay(500);
}

 

Setting Up The Keypad:

 

 

The following image shows how everything should be connected:

 

 

One thing I do need to mention is that there is 8 pins on the ByVac module instead of 7. There are 7 that look like pins, but there's another pin just to the right of that. That pin is R0. If you don't have 8 pins soldered you need to add another one.

After you've hooked everything up you need to run this code to program the keypad:

#include <ByVacLCD.h>
#include <Wire.h>

int keypushed;
int keymap;
int addr;

ByVacLCD lcd = ByVacLCD(0x21,4,20);

void setup()
{
  Serial.begin(9600);
  lcd.init();
  keymap = lcd.keymap();
  Serial.println("Starting Up.....");
  delay(8000);
 
for(int i = 0; i <= 11; i++){
  Serial.print("Please Press Key Only Once: "); 
  if(i == 10){
    Serial.println("*");
  }else if(i == 11){
    Serial.println("#");
  }else{
    Serial.println(i);
  }
  delay(5000);
  keypushed = lcd.get_key();
  addr = keymap + keypushed;
  lcd.EEPROM_write(addr, i);
  Serial.print("Writing Value: ");
  Serial.println(i);
  Serial.print("To Address: ");
  Serial.println(addr);
}
}

void loop()
{

Serial.println("Done Config");
delay(10000);

}

If you find that it's not giving your the correct key push after you've programmed it, you might need to do a hardware reset. To do this unhook the Vcc pin. Short the INT pin to ground and re-connect the Vcc pin. Keep holding the INT pin to ground and unhook the power again. Try again to program it.

Keypad Commands:

get_key();
Returns the most recent key that's been pushed. If no keys are being pushed it will return 15.

key_down();
Returns a 1 if the key is being held down.

key_query();
Returns how many keys are in the buffer.

clear_buffer();
The buffer can hold 16 keys. This function will empty the buffer.

clear_int();
Clear the interrupt pin (set it to LOW).

set_int();
Set the interrupt pin to HIGH.

LCD Commands:

coming soon

 

Feel free to leave a comment if you have any questions.

Add to Technorati Favorites