Simple single-color 8x8x8 LED Cube with AVRs
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

main.c 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * main.c
  3. *
  4. * Copyright 2012 Thomas Buck <xythobuz@me.com>
  5. *
  6. * This file is part of LED-Cube.
  7. *
  8. * LED-Cube is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * LED-Cube is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with LED-Cube. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <avr/io.h>
  22. #include <stdint.h>
  23. #include <util/delay.h>
  24. #include <avr/interrupt.h>
  25. #include <avr/wdt.h>
  26. #include "adc.h"
  27. #include "eq.h"
  28. #include "twislave.h"
  29. #ifndef F_CPU
  30. #define F_CPU 16000000L
  31. #endif
  32. int main(void) {
  33. uint8_t *music = result;
  34. MCUCSR = 0;
  35. wdt_disable();
  36. DDRB = 6; // LEDs as Output
  37. DDRC = 12; // MSGEQ7 Pins as Output
  38. DDRD = 0; // Nothing on this Port!
  39. twiInit(0x42); // All TWI action happens completely in the background.
  40. adcInit();
  41. equalizerInit();
  42. sei(); // Enable interrupts
  43. wdt_enable(WDTO_500MS); // Enable watchdog reset after 500ms
  44. twiSetDataToSend(music);
  45. while (1) {
  46. if (twiDataWasSent()) {
  47. PORTB ^= (1 << PB2); // Toggle for every transaction
  48. music = equalizerGet();
  49. twiSetDataToSend(music);
  50. }
  51. wdt_reset();
  52. }
  53. return 0;
  54. }