Author: Not specified Language: cpp
Description: Not specified Timestamp: 2013-06-01 16:34:07 +0000
View raw paste Reply
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37.  
  38.        
  39.  
  40. /*
  41.   DigitalReadSerial
  42.  Reads a digital input on pin 2, prints the result to the serial monitor
  43.  
  44.  This example code is in the public domain.
  45.  */
  46.  
  47. // digital pin 2 has a pushbutton attached to it. Give it a name:
  48. int pushButton = 2;
  49.  
  50. // the setup routine runs once when you press reset:
  51. void setup() {
  52.   // initialize serial communication at 9600 bits per second:
  53.   Serial.begin(9600);
  54.   // make the pushbutton's pin an input:
  55.   pinMode(pushButton, INPUT);
  56. }
  57.  
  58. template<typename T>
  59. struct base {
  60.   typedef int type;
  61. };
  62.  
  63. template<>
  64. struct base<double> {
  65.   typedef double type;
  66. };
  67.  
  68. // the loop routine runs over and over again forever:
  69. void loop() {
  70.   // read the input pin:
  71.   int buttonState = digitalRead(pushButton);
  72.   // print out the state of the button:
  73.   Serial.println(buttonState);
  74.   delay(1);        // delay in between reads for stability
  75. }
  76.  
  77.  
View raw paste Reply