Advertisement
NapsterMP3

SPI para DMX

Aug 30th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <DmxSimple.h>
  2. #include "SPI.h"
  3.  
  4. char canais [512];
  5. volatile boolean received_flag;
  6. int dmxpin = 5;
  7.  
  8. void setup() {
  9. DmxSimple.usePin(dmxpin);
  10.  
  11. SPCR |= bit (SPE);
  12.  
  13. pinMode(MISO, OUTPUT);
  14.  
  15. received_flag = false;
  16.  
  17. SPI.attachInterrupt();
  18.  
  19. }
  20.  
  21. void loop() {
  22.  
  23. if (received_flag){
  24.  
  25. for (int i=1;i<513;i++){
  26. DmxSimple.write(i,canais[i]);
  27. }
  28.  
  29.  
  30. received_flag = false;
  31. }
  32. }
  33.  
  34.  
  35. ISR (SPI_STC_vect) {
  36.  
  37. for (int i=1;i<513;i++){
  38. canais [i] = SPDR;
  39. }
  40.  
  41. received_flag = true;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement