Created
May 20, 2010 04:57
-
-
Save bnewbold/407221 to your computer and use it in GitHub Desktop.
Strobe lab pressure range detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "wirish.h" | |
#include "HardwareSerial.h" | |
#include "HardwareUsb.h" | |
#include "usb.h" | |
#define LED_PIN 13 | |
#define AIN_PIN 20 | |
#define CUTOFF1 3000 // 2/3.3 * 4096 | |
#define CUTOFF2 3350 // 2/3.3 * 4096 | |
HardwareUsb Usb; | |
void setup() | |
{ | |
/* Set up the LED to blink */ | |
pinMode(LED_PIN, OUTPUT); | |
/* Set up AIN */ | |
pinMode(AIN_PIN, INPUT_ANALOG); | |
/* Send a message out the USB virtual com port */ | |
Usb.println("Hello world! Measuring pressure..."); | |
} | |
int val = 0; | |
void loop() { | |
val = analogRead(AIN_PIN); | |
if(val > CUTOFF2) { | |
digitalWrite(LED_PIN, 1); | |
delay(40); | |
} else if(val > CUTOFF1) { | |
digitalWrite(LED_PIN, 0); | |
delay(40); | |
digitalWrite(LED_PIN, 1); | |
delay(40); | |
} else { | |
digitalWrite(LED_PIN, 0); | |
delay(100); | |
digitalWrite(LED_PIN, 1); | |
delay(100); | |
} | |
Usb.println(val,DEC); | |
} | |
int main(void) { | |
init(); | |
setup(); | |
while (1) { | |
loop(); | |
} | |
return 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment