Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 633 Bytes

README.md

File metadata and controls

33 lines (25 loc) · 633 Bytes

Arduino to Browser

Arduino to computer interaction

Arduino Script

This is for a hall sensor using an interrupt.

int interruptPin = 2;
bool state = LOW;
bool lastState;

void setup() {
    // runs once
    pinMode(interruptPin, INPUT_PULLUP);
    attachInterrupt(digitalPinToInterrupt(interruptPin), countSpeed, CHANGE);
    Serial.begin(9600);
  }

void loop() {
  // code here runs repeatedly in a loop
  if (state != lastState) {
    Serial.println(state);
    lastState = state;
  }
}

void countSpeed() {
  state = !state;
}