Created
May 2, 2016 21:01
Sketch for final project
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
One sketch is for button | |
One sketch is for force resistor |
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
int fsrPin = 4; | |
int secPin = 5;// the FSR and 10K pulldown are connected to a0 | |
int fsrReading; | |
int secReading; | |
int last1 = 0; | |
int last2 = 0;// the analog reading from the FSR resistor divider | |
void setup(void) { | |
Serial.begin(9600); // We'll send debugging information via the Serial monitor | |
} | |
void loop(void) { | |
fsrReading = analogRead(fsrPin); | |
secReading = analogRead(secPin); | |
if(fsrReading == 0 && last1 > 5){ | |
Serial.println("JumpLeft"); | |
delay(300); | |
} | |
last1 = fsrReading; | |
if(secReading == 0 && last2 > 5){ | |
Serial.println("JumpRight"); | |
delay(300); | |
} | |
last2 = secReading; | |
} |
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 <Adafruit_BLE.h> | |
#include <Adafruit_BluefruitLE_SPI.h> | |
Adafruit_BluefruitLE_SPI ble(8, 7, 6); | |
const int buttonPin = 12; | |
int lastpress = HIGH; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); | |
pinMode(buttonPin, INPUT_PULLUP); | |
ble.begin(false); | |
ble.setMode(BLUEFRUIT_MODE_DATA); | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
int pinState = digitalRead(buttonPin); | |
if (pinState == LOW && lastpress == HIGH) { | |
ble.println("1"); | |
delay(300); | |
} | |
lastpress = pinState; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment