Photon Servo And Distance - toSvenson/intro-workshop GitHub Wiki

Extra Experiment: Control Servo with Distance Sensor

In this extra experiment you will connect the servo with the distance sensor over the internet. One of the 2 could be on the other side of the globe and function in exactly the same way as you are going to experience.

Changes to the Distance Sensor

Open the online build environment of Particle.io on build.particle.io.

  • First we want to select the right Photon device, press DEVICES and click the yellow star in front of device PhotonSonar.
  • From the menu, press "< >" Code to open the code editor
  • In the My apps-list, select PhotonSonarApp to open the project you created earlier.
  • Look for //// Uncomment for extra experiment with Distance sensor and remove all //. You will see the code change from grey to colors.
  • From the menu, press VERIFY.
    This should result in the message Code verified! Great work.
  • Now you are ready to press FLASH
    If everything goes well, you will get a:
    Flash successful! Please wait a moment while your device is updated...
  • The Photon device should return to breading cyan status color

Changes to the Servo Actuator

Analog to the changes you made to the distance sensor.
Open the online build environment of Particle.io on build.particle.io.

  • First we want to select the right Photon device, press DEVICES and click the yellow star in front of device PhotonServo.
  • From the menu, press "< >" Code to open the code editor
  • In the My apps-list, select PhotonServoApp to open the project you created earlier.
  • Look for //// Uncomment for extra experiment with Distance sensor and remove all //. You will see the code change from grey to colors.
  • From the menu, press VERIFY.
    This should result in the message Code verified! Great work.
  • Now you are ready to press FLASH
    If everything goes well, you will get a:
    Flash successful! Please wait a moment while your device is updated...
  • The Photon device should return to breading cyan status color

Ready to give it a go!

Move your hand between 10-50cm of the sonar and see the servo move between 0 and 180°

Optionally you can monitor the events using your webbrowser with the Particle Dashboard. The Sonar sensor will send events with the name SetServoSon.