Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Bounce2.h>
- #define DEBOUNCE 10
- #include <M93Cx6.h>
- Bounce b1 = Bounce();
- /******************************************************************************
- **
- ** M93Cx6 Test Program
- **
- ** Pin-Out:
- ** _____
- ** Chip Select (cs) --|1 8|-- (pwr) Vcc
- ** Serial Clock (sk) --|2 7|--
- ** Data In (di) --|3 6|-- (org) Organization Select
- ** Data Out (do) --|4 5|-- (gnd) Vss/Ground
- ** -----
- **
- ** Arduino Connection:
- ** Vcc - +5v (or Pin 9 as an option)
- ** Vss - GND
- ** Chip Select - Pin 10
- ** Serial Clock - Pin 13
- ** Data In - Pin 11
- ** Data Out - Pin 12
- ** Org Select - Pin 8
- **
- *****************************************************************************/
- #define PWR_PIN 7
- #define CS_PIN 10
- #define SK_PIN 13
- #define DO_PIN 12
- #define DI_PIN 11
- #define ORG_PIN 8
- #define ORG 16
- #define CHIP 56
- const int ign = 2;
- int i = 0;
- int r;
- int ignstate = 0;
- M93Cx6 eeprom = M93Cx6(PWR_PIN, CS_PIN, SK_PIN, DO_PIN, DI_PIN, ORG_PIN);
- void setup() {
- b1.attach(2, INPUT);
- char hello[] = "Hello World!";
- Serial.begin(9600);
- eeprom.setChip(56); // set chip 93C56
- eeprom.setOrg(ORG_16); // 8-bit data organization
- // write string to eeprom
- // read string from eeprom
- //r = eeprom.read(1);
- //Serial.println(r);
- // clear eeprom
- //eeprom.writeEnable();
- // eeprom.eraseAll();
- // eeprom.writeDisable();
- }
- void loop() {
- // put your main code here, to run repeatedly:
- ignstate = digitalRead(ign);
- b1.update();
- if(b1.fell()){
- ignstate = 0;
- }
- if(b1.rose()){
- ignstate = 1;
- }
- if (ignstate == 0) {
- eeprom.writeEnable();
- //eeprom.eraseAll();
- eeprom.write(0, 65280);
- eeprom.write(1, 65481);
- eeprom.write(2, 65399);
- eeprom.write(3, 65294);
- eeprom.write(4, 65373);
- eeprom.write(5, 65496);
- eeprom.write(6, 65280);
- eeprom.write(7, 65280);
- eeprom.write(14, 37119);
- eeprom.write(32, 65365);
- eeprom.write(33, 65466);
- eeprom.write(34, 65440);
- eeprom.write(35, 65378);
- eeprom.write(36, 65377);
- eeprom.write(37, 65408);
- eeprom.write(38, 65465);
- eeprom.write(39, 65355);
- eeprom.writeDisable();
- }
- /*for (i = 0; i < 30; i++) {
- r = eeprom.read(i);
- Serial.println(r);
- }
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement