Writing Data to Arduino EEPROM -


this follow-up post here - writting data arduino's onboard eeprom tried using snippets in url wouldn't work. please me fix below error.

write_to_eeprom.cpp:8:5: error: expected unqualified-id before '[' token write_to_eeprom.cpp: in function 'void setup()': write_to_eeprom.cpp:12:16: error: 'stringtowrite' not declared in scope write_to_eeprom.cpp: in function 'void loop()': write_to_eeprom.cpp:22:33: error: invalid conversion 'uint8_t {aka unsigned char}' 'char*' [-fpermissive] write_to_eeprom.cpp: in function 'void eeprom_write(void*, byte)': write_to_eeprom.cpp:32:32: error: 'void*' not pointer-to-object type 

here code

#include <eeprom.h> #include <liquidcrystal.h> liquidcrystal lcd(8, 13, 9, 4, 5, 6, 7); char[] stringtowrite = "test"; void setup() {   lcd.begin(16, 2);   delay(5000);   eeprom_write(stringtowrite, strlen(stringtowrite)); }  void loop() {   delay(10000);   int addr = 0;   byte datasize = eeprom.read(addr++);   char stringtoread[0x20];          // allocate enough space string here!   char * readloc = stringtoread;   (int i=0;i<datasize; i++) {     readloc = eeprom.read(addr++);     readloc++;   } } // function takes void pointer data, , how write (no other way know) // take starting address, , return size of reach chunk, more generic void eeprom_write(void * data, byte datasize) {   int addr = 0;   eeprom.write(addr++, datasize);   (int i=0; i<datasize; i++) {     eeprom.write(addr++, data[i]);   } } 

well, need fix code:

line 8 -- [] needs go after stringtowrite line 12 -- should better after fixing line 8

line 22 -- need dereference readloc. add '*' before it.

line 32 -- parameter "data" pointer void, has no size. because of that, not able use array. change declaration to:

void eeprom_write(char * data, byte datasize)

that fixes compiler errors. taking quick @ semantics of code seems doing want. luck.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -