I learned python for this project. The python code is going to control the servos.
Copy servo.py file on GitHub.
Just like in the Java code, you need to put your personal PubNub publish and subscribe keys in here, as well as the name of your communication channel. –> which I have a trouble with.
The Pi will do the following on boot:
- Reset the AVR matrix driver circuit.
- Initialize PubNub with your keys
- Subscribe to the PubNub channel “leap2pi”
- Loop forever, checking an output mode switch (more on this in a minute)
- MIRROR – The bots will mirror your movements; hence, your left hand inversely controls the right bot so I am going to use this to let a robotic arm copies kids’ handwriting.
- DISABLED – The servos will be unresponsive
- CLONE – The bots will clone your movements; hence your left hand directly controls the left bot. I am going to use this to train autistic kids’ hand writing and rehabilitation purposes.
The only other item of note in this file is the use of GPIO pin 4 as an output.