Theremin

Untitled

May 24th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.62 KB | None | 0 0
  1. /*
  2. Magnetometer read and serial output
  3.  
  4. Pinout:
  5. TX 0
  6. RX 1
  7. Mag 3
  8. Led 8
  9. Button 7
  10. LDR 2
  11. */
  12.  
  13. #include <SoftwareSerial.h>
  14.  
  15. SoftwareSerial ser(0,1);
  16.  
  17. //pin defines
  18. const int tx = 0;
  19. const int rx = 1;
  20. const int magPin = 3;
  21. const int ldrPin = 2;
  22. const int btn = 7;
  23. const int led = 8;
  24.  
  25. void setup() {
  26.   ser.begin(9600); //init serial, set baudrate
  27. }
  28.  
  29. void loop() {
  30.   digitalWrite(led, HIGH);
  31.   //read sensor values
  32.   int magVal = analogRead(magPin);
  33.   int lightVal = analogRead(ldrPin);
  34.  
  35.   //send sensor values
  36.   ser.println(magVal);
  37.   ser.println(lightVal);
  38.   digitalWrite(led, LOW);
  39.   delay(100);  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment