Advertisement
Guest User

ArduinoMaster

a guest
Mar 19th, 2017
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #include <Wire.h>
  2. int readstate=0;
  3. //This is the master arduino, currently it reads the address bus and sends it to the arduino handling memory
  4. //Currently untested
  5. void setup() {
  6.  
  7. pinMode(2, INPUT);
  8. pinMode(3, INPUT);
  9. pinMode(4, INPUT);
  10. pinMode(5, INPUT);
  11. pinMode(6, INPUT);
  12. pinMode(7, INPUT);
  13. pinMode(8, INPUT);
  14. pinMode(9, INPUT);
  15. pinMode(10, INPUT);
  16. pinMode(11, INPUT);
  17. pinMode(12, INPUT);
  18. pinMode(13, INPUT);
  19.  
  20. pinMode(A0, INPUT);
  21. pinMode(A1, INPUT);
  22. pinMode(A2, INPUT);
  23. pinMode(A3, INPUT);
  24. pinMode(A7, INPUT);
  25. Wire.begin();
  26. }
  27.  
  28. int rpin(int pin) {
  29. int r1 = digitalRead(pin);
  30. return r1;
  31.  
  32. }
  33.  
  34.  
  35.  
  36. void loop() {
  37.  
  38. readstate = digitalRead(A7);
  39. if(readstate == 0){
  40. //needs to be a conditional here that depends on the state of RD?
  41.  
  42. //grab address bus from pins, store in addr
  43. int addr[16] ={rpin(12),rpin(11),rpin(10),rpin(9),rpin(8),rpin(7),rpin(6),rpin(5),rpin(4),rpin(3),rpin(2),rpin(13),rpin(A0),rpin(A1),rpin(A2),rpin(A3)};
  44. Wire.beginTransmission(8); // transmit to device #8
  45. Wire.print(addr[0]);
  46. Wire.print(addr[1]);
  47. Wire.print(addr[2]);
  48. Wire.print(addr[3]);
  49. Wire.print(addr[4]);
  50. Wire.print(addr[5]);
  51. Wire.print(addr[6]);
  52. Wire.print(addr[7]);
  53. Wire.print(addr[8]);
  54. Wire.print(addr[9]);
  55. Wire.print(addr[10]);
  56. Wire.print(addr[11]);
  57. Wire.print(addr[12]);
  58. Wire.print(addr[13]);
  59. Wire.print(addr[14]);
  60. Wire.print(addr[15]);
  61. Wire.print(addr[16]);
  62. //no matching function for call to 'TwoWire::write(int [16], int)'
  63. Wire.endTransmission();
  64.  
  65.  
  66. // delay(500); //Ideally this should not be here
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement