Guest User

Untitled

a guest
May 26th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include "wirish.h"
  2. #include "HardwareSerial.h"
  3. #include "HardwareUsb.h"
  4. #include "usb.h"
  5.  
  6. #define LED_PIN 13
  7. #define AIN_PIN 20
  8. #define CUTOFF1 3000 // 2/3.3 * 4096
  9. #define CUTOFF2 3350 // 2/3.3 * 4096
  10.  
  11. HardwareUsb Usb;
  12.  
  13. void setup()
  14. {
  15. /* Set up the LED to blink */
  16. pinMode(LED_PIN, OUTPUT);
  17.  
  18. /* Set up AIN */
  19. pinMode(AIN_PIN, INPUT_ANALOG);
  20.  
  21. /* Send a message out the USB virtual com port */
  22. Usb.println("Hello world! Measuring pressure...");
  23.  
  24. }
  25.  
  26. int val = 0;
  27.  
  28. void loop() {
  29. val = analogRead(AIN_PIN);
  30. if(val > CUTOFF2) {
  31. digitalWrite(LED_PIN, 1);
  32. delay(40);
  33. } else if(val > CUTOFF1) {
  34. digitalWrite(LED_PIN, 0);
  35. delay(40);
  36. digitalWrite(LED_PIN, 1);
  37. delay(40);
  38. } else {
  39. digitalWrite(LED_PIN, 0);
  40. delay(100);
  41. digitalWrite(LED_PIN, 1);
  42. delay(100);
  43. }
  44. Usb.println(val,DEC);
  45. }
  46.  
  47.  
  48. int main(void) {
  49. init();
  50. setup();
  51.  
  52. while (1) {
  53. loop();
  54. }
  55. return 0;
Add Comment
Please, Sign In to add comment