Advertisement
Guest User

lcdmsgeq7arduinolukebct

a guest
Nov 1st, 2011
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2. LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );
  3.  
  4. int analogPin = 1; // read from multiplexer using analog input 0
  5. int strobePin = 11; // strobe is attached to digital pin 2
  6. int resetPin = 10; // reset is attached to digital pin 3
  7. int spectrumValue[7]; // to hold a2d values
  8.  
  9. void setup()
  10. {
  11. Serial.begin(9600);
  12. pinMode(analogPin, INPUT);
  13. pinMode(strobePin, OUTPUT);
  14. pinMode(resetPin, OUTPUT);
  15. analogReference(DEFAULT);
  16.  
  17. digitalWrite(resetPin, LOW);
  18. digitalWrite(strobePin, HIGH);
  19.  
  20. lcd.begin(16, 2);
  21. }
  22.  
  23. void loop()
  24. {
  25. digitalWrite(resetPin, HIGH);
  26. digitalWrite(resetPin, LOW);
  27.  
  28. for (int i = 0; i < 7; i++)
  29. {
  30. digitalWrite(strobePin, LOW);
  31. delayMicroseconds(30); // to allow the output to settle
  32. spectrumValue[i] = analogRead(analogPin);
  33.  
  34. // comment out/remove the serial stuff to go faster
  35. // - its just here for show
  36.  
  37. if (spectrumValue[i] < 60)
  38. {
  39. Serial.print(" ");
  40. Serial.print(spectrumValue[i]);
  41.  
  42. }
  43. else if (spectrumValue[i] < 300 )
  44. {
  45. Serial.print(" ");
  46. Serial.print(spectrumValue[i]);
  47. // lcd.print(i);
  48. // lcd.print(" ");
  49. }
  50. else
  51. {
  52. Serial.print(" ");
  53. Serial.print(spectrumValue[i]);
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. //LCD
  63.  
  64. if (spectrumValue[0] > 300) {
  65. lcd.clear();
  66. lcd.print("Bass is high");
  67.  
  68. }
  69. else if (spectrumValue[2] > 300 )
  70. {
  71. lcd.clear();
  72. lcd.print("Midrange is high");
  73. }
  74.  
  75. else if (spectrumValue[3] > 300 )
  76. {
  77. lcd.clear();
  78. lcd.print("Midrange is high");
  79. }
  80.  
  81. else if (spectrumValue[4] > 300 )
  82. {
  83. lcd.clear();
  84. lcd.print("High mids are high");
  85. }
  86.  
  87. else if (spectrumValue[5] > 300 )
  88. {
  89. lcd.clear();
  90. lcd.print("Experiencing High Frequencies");
  91. }
  92.  
  93. else if (spectrumValue[6] > 300 )
  94. {
  95. lcd.clear();
  96. lcd.print("HIGH FREQUENCIES WOW");
  97. }
  98. else {
  99. lcd.clear();
  100. }
  101.  
  102. digitalWrite(strobePin, HIGH);
  103. }
  104. Serial.println();
  105. }
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement