Advertisement
Guest User

immo sketch

a guest
May 10th, 2021
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. #include <Bounce2.h>
  2. #define DEBOUNCE 10
  3. #include <M93Cx6.h>
  4. Bounce b1 = Bounce();
  5. /******************************************************************************
  6. **
  7. ** M93Cx6 Test Program
  8. **
  9. ** Pin-Out:
  10. ** _____
  11. ** Chip Select (cs) --|1 8|-- (pwr) Vcc
  12. ** Serial Clock (sk) --|2 7|--
  13. ** Data In (di) --|3 6|-- (org) Organization Select
  14. ** Data Out (do) --|4 5|-- (gnd) Vss/Ground
  15. ** -----
  16. **
  17. ** Arduino Connection:
  18. ** Vcc - +5v (or Pin 9 as an option)
  19. ** Vss - GND
  20. ** Chip Select - Pin 10
  21. ** Serial Clock - Pin 13
  22. ** Data In - Pin 11
  23. ** Data Out - Pin 12
  24. ** Org Select - Pin 8
  25. **
  26. *****************************************************************************/
  27.  
  28. #define PWR_PIN 7
  29. #define CS_PIN 10
  30. #define SK_PIN 13
  31. #define DO_PIN 12
  32. #define DI_PIN 11
  33. #define ORG_PIN 8
  34. #define ORG 16
  35. #define CHIP 56
  36. const int ign = 2;
  37. int i = 0;
  38. int r;
  39. int ignstate = 0;
  40. M93Cx6 eeprom = M93Cx6(PWR_PIN, CS_PIN, SK_PIN, DO_PIN, DI_PIN, ORG_PIN);
  41.  
  42. void setup() {
  43. b1.attach(2, INPUT);
  44.  
  45. char hello[] = "Hello World!";
  46. Serial.begin(9600);
  47.  
  48. eeprom.setChip(56); // set chip 93C56
  49. eeprom.setOrg(ORG_16); // 8-bit data organization
  50.  
  51. // write string to eeprom
  52.  
  53. // read string from eeprom
  54. //r = eeprom.read(1);
  55. //Serial.println(r);
  56. // clear eeprom
  57. //eeprom.writeEnable();
  58. // eeprom.eraseAll();
  59. // eeprom.writeDisable();
  60. }
  61.  
  62. void loop() {
  63. // put your main code here, to run repeatedly:
  64. ignstate = digitalRead(ign);
  65. b1.update();
  66. if(b1.fell()){
  67. ignstate = 0;
  68. }
  69. if(b1.rose()){
  70. ignstate = 1;
  71. }
  72. if (ignstate == 0) {
  73. eeprom.writeEnable();
  74.  
  75. //eeprom.eraseAll();
  76. eeprom.write(0, 65280);
  77. eeprom.write(1, 65481);
  78. eeprom.write(2, 65399);
  79. eeprom.write(3, 65294);
  80. eeprom.write(4, 65373);
  81. eeprom.write(5, 65496);
  82. eeprom.write(6, 65280);
  83. eeprom.write(7, 65280);
  84. eeprom.write(14, 37119);
  85. eeprom.write(32, 65365);
  86. eeprom.write(33, 65466);
  87. eeprom.write(34, 65440);
  88. eeprom.write(35, 65378);
  89. eeprom.write(36, 65377);
  90. eeprom.write(37, 65408);
  91. eeprom.write(38, 65465);
  92. eeprom.write(39, 65355);
  93. eeprom.writeDisable();
  94. }
  95.  
  96. /*for (i = 0; i < 30; i++) {
  97. r = eeprom.read(i);
  98. Serial.println(r);
  99. }
  100. */
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement