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
DEVICESand click the yellow star in front of devicePhotonSonar. - From the menu, press
"< >" Codeto open the code editor - In the
My apps-list, selectPhotonSonarAppto open the project you created earlier. - Look for
//// Uncomment for extra experiment with Distance sensorand remove all//. You will see the code change from grey to colors. - From the menu, press
VERIFY.
This should result in the messageCode 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 cyanstatus 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
DEVICESand click the yellow star in front of devicePhotonServo. - From the menu, press
"< >" Codeto open the code editor - In the
My apps-list, selectPhotonServoAppto open the project you created earlier. - Look for
//// Uncomment for extra experiment with Distance sensorand remove all//. You will see the code change from grey to colors. - From the menu, press
VERIFY.
This should result in the messageCode 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 cyanstatus 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.