This document contains functions for controlling an LCD display and reading/writing data to EEPROM memory on an Arduino. It includes functions for initializing the LCD, writing text to the LCD at a given line and column, clearing the LCD display, and writing robot position data from variables to EEPROM memory locations. It also includes functions for reading data from EEPROM memory locations and displaying it on the serial monitor.
This document contains functions for controlling an LCD display and reading/writing data to EEPROM memory on an Arduino. It includes functions for initializing the LCD, writing text to the LCD at a given line and column, clearing the LCD display, and writing robot position data from variables to EEPROM memory locations. It also includes functions for reading data from EEPROM memory locations and displaying it on the serial monitor.
This document contains functions for controlling an LCD display and reading/writing data to EEPROM memory on an Arduino. It includes functions for initializing the LCD, writing text to the LCD at a given line and column, clearing the LCD display, and writing robot position data from variables to EEPROM memory locations. It also includes functions for reading data from EEPROM memory locations and displaying it on the serial monitor.
This document contains functions for controlling an LCD display and reading/writing data to EEPROM memory on an Arduino. It includes functions for initializing the LCD, writing text to the LCD at a given line and column, clearing the LCD display, and writing robot position data from variables to EEPROM memory locations. It also includes functions for reading data from EEPROM memory locations and displaying it on the serial monitor.
Download as TXT, PDF, TXT or read online from Scribd
Download as txt, pdf, or txt
You are on page 1of 2
// function for LCD control ============================================
void lcdw (int lcdf, int lcdl, int lcdc, String lcdt) {
// Setting of the function ====================
// lcdf : 0=init LCD for void setup/1=write txt/2=clear display, // lcdl : for lcdf=1 display line number 0-1, // lcdc : for lcdf=1 display column number 0-15, // lcdt : for lcdf=1 string to diplay, // End setting of the function ================
// Function start =============================
// const static String lcds1 =" "; switch (lcdf) { case 0: lcd.setBacklight(255); lcd.home(); lcd.clear(); delay(100); break; case 1: lcd.setBacklight(255); lcd.setCursor(lcdc, lcdl); // set start for write lcd.print(lcdt); // write info break; case 2: lcd.clear(); // clear LCD break; } /* Other LCD functions which can be included in this function to improve it lcd.clear(); lcd.print("Cursor Blink"); lcd.noBlink(); lcd.blink(); lcd.noCursor(); lcd.noDisplay(); lcd.display(); lcd.setCursor(0-15, 0-1); lcd.scrollDisplayLeft(); lcd.scrollDisplayRight(); lcd.setBacklight(0-255); */ } // =================================== write robot postion to eeprom void writeprom(int writeprom1){ int writeprom3[6]; writeprom3[0] = tabserpos[0]; writeprom3[1] = tabserpos[1]; writeprom3[2] = tabserpos[2]; writeprom3[3] = tabserpos[3]; writeprom3[4] = tabserpos[4]; writeprom3[5] = tabserpos[5]; writeeeprom((writeprom1*6 + 2),writeprom3,6) ; // writes robot position to eeprom if (epractmax[0] > epractmax[1]) { epractmax[1] = epractmax[0]; } writeeeprom(0,epractmax,2); // writes eeprom pointers to eeprom if (lcdpres == 1) { lcdw(2,0,0,""); lcdw(1,0,0,"Write OK"); lcdw(1,1,0,String (epractmax[0]) + "-" + String (epractmax[1])); } Serial.println("Write OK "); listpos(); } // =================================== eeprom write function void writeeeprom(int data_addr, int stotab[], int len) { Wire.beginTransmission(EEPROM_I2C_ADDRESS); Wire.write((int)(data_addr >>8)); Wire.write((int)(data_addr & 0xFF)); for (int i=0;i!=len; i++) { Wire.write(stotab[i]);} // writes "len number" memory cells Wire.endTransmission(); delay(5); } // =================================== eeprom read function byte readeeprom(int data_addr, int len) { int i=0; Wire.beginTransmission(EEPROM_I2C_ADDRESS); Wire.write((int)(data_addr >>8)); Wire.write((int)(data_addr & 0xFF)); Wire.endTransmission(); Wire.requestFrom(EEPROM_I2C_ADDRESS, len); // request to return "len" memory cells delay(10); while (Wire.available()){ eprdata[i] = Wire.read(); i=i+1; } } // =================================== eeprom read and disply on computer void eeprom_read_test() { String str; int j, k=0 ,l=0; for(int i=2;i<100;i++) { j = (i-2)/6 ; if (k != j) { k = j; l = 0;} readeeprom(i,1); delay(10) ; l = l+1; str = "Position - Servo : " + String((i-2)/6) + " - " + String(l) + " value : " + String(eprdata[0]); Serial.println(str) ; } Serial.println("End list"); } // =================================== Init 30 firts eeprom cells to 0 void reinitI2CByte() { int data_addr = 0; Wire.beginTransmission(EEPROM_I2C_ADDRESS); Wire.write((int)(data_addr >>8)); Wire.write((int)(data_addr & 0xFF)); for (int i=0;i < 30; i++) { Wire.write(0);} // writes 0 to cells Wire.endTransmission(); delay(5); }