George StewartAndrew Blankenship
Published

MEGR 3171 MTB Dropper Post Sensor

An automatic suspension fork compression changing device that responds to dropper post movement.

IntermediateFull instructions provided637
MEGR 3171 MTB Dropper Post Sensor

Things used in this project

Hardware components

Photon
Particle Photon
×2
Servo Module (Generic)
×1
Proximity Sensor
Proximity Sensor
×1
4xAA battery holder
4xAA battery holder
×2
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2
Male/Male Jumper Wires
×10

Software apps and online services

Particle Pi
Particle Pi

Story

Read more

Schematics

Servo Photon Schematic

This is a fritzing application file

Sensor Photon Schematic

This is a fritzing application file

Code

Servo Photon Code

C/C++
Servo myservo; //creates the servo to be used
void setup() {
Particle.publish("light", "devices talking"); //publishes to the cloud to confirm the photons are communicating
Particle.subscribe("seatpost", myHandler); //subscribes to the event seatpost published by the other photon
}


void myHandler(const char *event, const char *data)
{

 if (strcmp(data,"SeatUp")==0) { //tells the servo to turn to a specific angle if  the photon reads the seat up function from the cloud
myservo.attach(D0);
myservo.write(180);
delay(2000);
myservo.detach();

}
else if (strcmp(data,"SeatDown")==0) { //tells the servo to turn to a specific angle if the photon reads the seat up function from the cloud
myservo.attach(D0);
myservo.write(110);
delay(2000);
myservo.detach();
}
 
}

Sensor Photon Code

C/C++
int sensor = D4;  //sets up the sensor as connected to D4

void myHandler(const char *event, const char *data)
{}
void setup() {
pinMode(sensor,INPUT);
Particle.subscribe("light", myHandler); //subscribes to the cloud event published by the other photon to confirm                                                   connection
}
void loop() {

{
if (digitalRead(sensor)==HIGH){ //Publishes the seat up event if the proximity sensor gets a reading that triggers it
    
    Particle.publish("seatpost","SeatUp",PUBLIC);
    delay(2000);
    System.sleep(40); //onlyl publishes to the cloud once per loop
   
}
else if (digitalRead(sensor)==LOW){ //publishes the seat down event if the proximity sensor does not read the seat as being close
    Particle.publish("seatpost","SeatDown",PUBLIC);
    delay(2000);
    System.sleep(40); //only publishes to the cloud once per loop
}}}



    

Credits

George Stewart

George Stewart

1 project • 1 follower
Andrew Blankenship

Andrew Blankenship

1 project • 0 followers

Comments