Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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;
Add Comment
Please, Sign In to add comment