Skip to content

Instantly share code, notes, and snippets.

@sunnyuxuan
Created May 2, 2016 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunnyuxuan/178c5f75cd0d8bb49620786648c34d47 to your computer and use it in GitHub Desktop.
Save sunnyuxuan/178c5f75cd0d8bb49620786648c34d47 to your computer and use it in GitHub Desktop.
Sketch for final project
One sketch is for button
One sketch is for force resistor
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;
}
#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