Skip to content

Instantly share code, notes, and snippets.

@bnewbold
Created May 20, 2010 04:57
Show Gist options
  • Save bnewbold/407221 to your computer and use it in GitHub Desktop.
Save bnewbold/407221 to your computer and use it in GitHub Desktop.
Strobe lab pressure range detection
#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