Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 30th, 2012  |  syntax: None  |  size: 4.53 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*****************
  2. By Param Aggarwal
  3. www.feemo.in
  4.  
  5. AccPOV
  6. Uses an accelerometer to sense when it is being waved in the air.
  7. Uses Arduino Decimilia and Accelerometer and a custom made shield for the Arduino.
  8. *******************/
  9.  
  10. // Display goes on PORTD
  11. // GS1 on 10 Sensitivity Selection pins
  12. // GS2 on 11 +- 4g selected here
  13. // SLEEP on 12 and active LOW
  14.  
  15. int GS1 = 10;
  16. int GS2 = 11;
  17. int SLEEP = 12;
  18.  
  19. int Y=0; // Temp
  20. int p=0; //Temp
  21.  
  22. // Tells the microcontroller how to write letters. Little Kid.
  23. // Taken from Sparkfun Library
  24. int text_array[475] = {
  25. 0x00,0x00,0x00,0x00,0x00,/*space*/ // is 32 in ASCII
  26. 0x00,0xF6,0xF6,0x00,0x00,/*!*/
  27. 0x00,0xE0,0x00,0xE0,0x00,/*"*/
  28. 0x28,0xFE,0x28,0xFE,0x28,/*#*/
  29. 0x00,0x64,0xD6,0x54,0x08,/*$*/
  30. 0xC2,0xCC,0x10,0x26,0xC6,/*%*/
  31. 0x4C,0xB2,0x92,0x6C,0x0A,/*&*/
  32. 0x00,0x00,0xE0,0x00,0x00,/*'*/
  33. 0x00,0x38,0x44,0x82,0x00,/*(*/
  34. 0x00,0x82,0x44,0x38,0x00,/*)*/
  35. 0x88,0x50,0xF8,0x50,0x88,/***/
  36. 0x08,0x08,0x3E,0x08,0x08,/*+*/
  37. 0x00,0x00,0x05,0x06,0x00,/*,*/
  38. 0x08,0x08,0x08,0x08,0x08,/*-*/
  39. 0x00,0x00,0x06,0x06,0x00,/*.*/
  40. 0x02,0x0C,0x10,0x60,0x80,/*/*/
  41. 0x7C,0x8A,0x92,0xA2,0x7C,/*0*/
  42. 0x00,0x42,0xFE,0x02,0x00,/*1*/
  43. 0x42,0x86,0x8A,0x92,0x62,/*2*/
  44. 0x44,0x82,0x92,0x92,0x6C,/*3*/
  45. 0x10,0x30,0x50,0xFE,0x10,/*4*/
  46. 0xE4,0xA2,0xA2,0xA2,0x9C,/*5*/
  47. 0x3C,0x52,0x92,0x92,0x0C,/*6*/
  48. 0x80,0x86,0x98,0xE0,0x80,/*7*/
  49. 0x6C,0x92,0x92,0x92,0x6C,/*8*/
  50. 0x60,0x92,0x92,0x94,0x78,/*9*/
  51. 0x00,0x00,0x36,0x36,0x00,/*:*/
  52. 0x00,0x00,0x35,0x36,0x00,/*;*/
  53. 0x10,0x28,0x44,0x82,0x00,/*<*/
  54. 0x28,0x28,0x28,0x28,0x28,/*=*/
  55. 0x00,0x82,0x44,0x28,0x10,/*>*/
  56. 0x40,0x80,0x8A,0x90,0x60,/*?*/
  57. 0x7C,0x82,0xBA,0xBA,0x62,/*@*/
  58. 0x3E,0x48,0x88,0x48,0x3E,/*A*/
  59. 0xFE,0x92,0x92,0x92,0x6C,/*B*/
  60. 0x7C,0x82,0x82,0x82,0x44,/*C*/
  61. 0xFE,0x82,0x82,0x82,0x7C,/*D*/
  62. 0xFE,0x92,0x92,0x92,0x82,/*E*/
  63. 0xFE,0x90,0x90,0x90,0x80,/*F*/
  64. 0x7C,0x82,0x82,0x8A,0x4E,/*G*/
  65. 0xFE,0x10,0x10,0x10,0xFE,/*H*/
  66. 0x82,0x82,0xFE,0x82,0x82,/*I*/
  67. 0x84,0x82,0xFC,0x80,0x80,/*J*/
  68. 0xFE,0x10,0x28,0x44,0x82,/*K*/
  69. 0xFE,0x02,0x02,0x02,0x02,/*L*/
  70. 0xFE,0x40,0x20,0x40,0xFE,/*M*/
  71. 0xFE,0x60,0x10,0x0C,0xFE,/*N*/
  72. 0x7C,0x82,0x82,0x82,0x7C,/*O*/
  73. 0xFE,0x90,0x90,0x90,0x60,/*P*/
  74. 0x7C,0x82,0x82,0x86,0x7E,/*Q*/
  75. 0xFE,0x90,0x98,0x94,0x62,/*R*/
  76. 0x64,0x92,0x92,0x92,0x4C,/*S*/
  77. 0x80,0x80,0xFE,0x80,0x80,/*T*/
  78. 0xFC,0x02,0x02,0x02,0xFC,/*U*/
  79. 0xF8,0x04,0x02,0x04,0xF8,/*V*/
  80. 0xFC,0x02,0x0C,0x02,0xFC,/*W*/
  81. 0xC6,0x28,0x10,0x28,0xC6,/*X*/
  82. 0xC0,0x20,0x1E,0x20,0xC0,/*Y*/
  83. 0x86,0x8A,0x92,0xA2,0xC2,/*Z*/
  84. 0x00,0x00,0xFE,0x82,0x00,/*[*/
  85. 0x00,0x00,0x00,0x00,0x00,/*this should be / */
  86. 0x80,0x60,0x10,0x0C,0x02,/*]*/
  87. 0x20,0x40,0x80,0x40,0x20,/*^*/
  88. 0x01,0x01,0x01,0x01,0x01,/*_*/
  89. 0x80,0x40,0x20,0x00,0x00,/*`*/
  90. 0x04,0x2A,0x2A,0x2A,0x1E,/*a*/
  91. 0xFE,0x12,0x22,0x22,0x1C,/*b*/
  92. 0x1C,0x22,0x22,0x22,0x14,/*c*/
  93. 0x1C,0x22,0x22,0x12,0xFE,/*d*/
  94. 0x1C,0x2A,0x2A,0x2A,0x18,/*e*/
  95. 0x10,0x7E,0x90,0x80,0x40,/*f*/
  96. 0x18,0x25,0x25,0x25,0x1E,/*g*/
  97. 0xFE,0x10,0x10,0x10,0x0E,/*h*/
  98. 0x00,0x12,0x5E,0x02,0x00,/*i*/
  99. 0x02,0x01,0x01,0x11,0x5E,/*j*/
  100. 0xFE,0x08,0x08,0x14,0x22,/*k*/
  101. 0x00,0x82,0xFE,0x02,0x00,/*l*/
  102. 0x3E,0x20,0x1C,0x20,0x1E,/*m*/
  103. 0x3E,0x20,0x20,0x20,0x1E,/*n*/
  104. 0x1C,0x22,0x22,0x22,0x1C,/*o*/
  105. 0x3F,0x24,0x24,0x24,0x18,/*p*/
  106. 0x18,0x24,0x24,0x3F,0x01,/*q*/
  107. 0x3E,0x10,0x20,0x20,0x10,/*r*/
  108. 0x12,0x2A,0x2A,0x2A,0x04,/*s*/
  109. 0x00,0x10,0x3C,0x12,0x04,/*t*/
  110. 0x3C,0x02,0x02,0x02,0x3E,/*u*/
  111. 0x30,0x0C,0x02,0x0C,0x30,/*v*/
  112. 0x38,0x06,0x18,0x06,0x38,/*w*/
  113. 0x22,0x14,0x08,0x14,0x22,/*x*/
  114. 0x38,0x05,0x05,0x05,0x3E,/*y*/
  115. 0x22,0x26,0x2A,0x32,0x22,/*z*/
  116. 0x00,0x10,0x6C,0x82,0x82,/*{*/
  117. //0x00,0x00,0xFF,0x00,0x00,/*|*/
  118. 0x04,0x02,0xFF,0x02,0x04,/*|, arrow*/
  119. 0x82,0x82,0x6C,0x10,0x00,/*}*/
  120. 0x08,0x10,0x18,0x08,0x10/*~*/
  121. };
  122.  
  123. // Displays the text
  124. void display(char c)
  125. {
  126.         int i = (c - 32)*5;
  127.         for ( int temp = i; temp < i + 5; temp++ ) {
  128.                 PORTD = text_array[temp]; delayMicroseconds(500);
  129.                 PORTD = 0x00; delay(3);
  130.         }
  131.         PORTD = 0x00; delay(3);
  132. }
  133.  
  134. void setup()
  135. {
  136.         pinMode(0,OUTPUT); // Set display as OUTPUT
  137.         pinMode(1,OUTPUT);
  138.         pinMode(2,OUTPUT);
  139.         pinMode(3,OUTPUT);
  140.         pinMode(4,OUTPUT);
  141.         pinMode(5,OUTPUT);
  142.         pinMode(6,OUTPUT);
  143.         pinMode(7,OUTPUT);
  144.         pinMode(8,OUTPUT);
  145.         pinMode(9,OUTPUT);
  146.         pinMode(10,OUTPUT);
  147.         pinMode(11,OUTPUT);
  148.         pinMode(12,OUTPUT);
  149.         pinMode(13,OUTPUT);
  150.  
  151.         digitalWrite(GS1,HIGH); // Sensitivity Select
  152.         digitalWrite(GS2,LOW);
  153.         digitalWrite(SLEEP,HIGH); // Don't let the Accelerometer sleep !!!
  154. }
  155.  
  156. void loop()
  157. {
  158.         Y = analogRead(1); // Read the sensor...
  159.         if ( Y > 650)
  160.         {
  161.                 p++;
  162.                 if(p=2) // Take alternate acceleration...
  163.                 {
  164.                         p=0;
  165.                         delay(60); // Wait a moment before starting
  166.  
  167.                         display('P'); // Paaaaraaammm...
  168.                         display('a');
  169.                         display('r');
  170.                         display('a');
  171.                         display('m');
  172.                         display(':');
  173.                         display('-');
  174.                         display(')');
  175.                         display(' ');
  176.                 }
  177.         }
  178. }