Let's start by setting up the Raspberry Pi:
- Download the Raspbian operating system here : https://www.raspberrypi.org/downloads/raspbian/
- Unzip the Raspbian zip file
- Use Etcher (https://www.balena.io/etcher/) to write the disc image into the microSD card
- Insert the microSD card in the Raspberry Pi and boot to Raspbian
- Make sure your Pi is connected to the internet.
- You can also find a tutorial on how to set-up your Raspberry Pi on their website: https://projects.raspberrypi.org/en/pathways/getting-started-with-raspberry-pi
- Connect the Raspberry Pi to the LSS Adapter Board using a USB cable, and then connect the Lynxmotion Smart Servo to the LSS Adapter.
The Raspberry Pi can be powered by a 5V micro USB supply (for more information on Raspberry Pi power supply). The LSS needs a separate power supply. It can be powered through the XT60 connector on the adapter board with a 6V to 12V power supply. Take a look in the LSS Wiki for more information on LSS power specifications .
- Power the LSS Adapter using a wall adapter (preferable) or an LSS compatible battery pack. This is ideally done via the XT60 connector.
- Power the Raspberry Pi using a compatible USB wall adapter (you can use a battery in the future, but for testing it's always best to have unlimited power)
The library is available for download on Lynxmotion's GitHub page, though you can install it directly from the Raspberry Pi:
- Open LXTerminal that can be found in the taskbar
- Type (or copy and paste) the following then press enter:
git clone https://github.com/Lynxmotion/LSS_Library_Python.git
- The Python library and examples can now be found in /home/pi/LSS_Library_Python/src
- Open example_sweep.py with Thonny (double click the example_sweep.py file)
- Make sure you modify the code as shown in the picture below.
- Uncomment but do not delete (just remove the "#" in front) the following line:
CST_LSS_Port = "/dev/ttyUSB"
- Comment (Add an "#") to the line below it.
- Click the "Run" button to run the example; the servo should rotate back and forth.
If you want your Raspberry Pi to run the code as soon as it is powered on, here's a quick guide:
- Open the LXTerminal as above
- Type the following : sudo nano /etc/profile
- Scroll to the bottom and add the following line : sudo python /home/pi/LSS_Library_Python/src/example_sweep.py
- Type “Ctrl+X” to exit, then “Y” to save followed by “Enter” twice.
- To test if this has worked reboot your Pi using : sudo reboot
That's it! You can now use the Lynxmotion's smart servos with your Raspberry Pi. If you want to use standoffs to mount the LSS Adapter on top of the Raspberry Pi (or below), the LSS adapter's four hole mounting pattern line up with the Raspberry Pi's four mounting holes. However, it is important to mention that the Raspberry Pi's holes are of a smaller diameter than the LSS Adapter, so choose standoffs and screws accordingly.
If you have any questions leave them in the comments and we will be happy to help. We will update the post to confirm this works well with the Raspberry Pi model 4.