You are viewing an older revision! See the latest version
instructions
FTF: using and control Servo and Temperature Robotics on a microcontroller, instructions¶
Welcome to our session at FTF! If you have any questions, please just give a shout. We are here to help.
In this session we'll work through 4 examples together. We will demonstrate everything, but this document should help you in case you're stuck. We also have optional sections in case you want to go further.
If you happen to be much faster than everyone else, help your neighbors.
Setup¶
- Connect the Temperature sensor as well as the Servo to the Seeeduino-Arch board, and then connect the board to you PC using the micro-USB cable.
- The board mounts as a mass-storage device (like a USB drive). Verify that you can see it (drive name will be MBED).
- Go to http://developer.mbed.org
- Create an ARM mbed account if you do not have one.
- On the top right corner, click the Compiler button.
An IDE should open. Congratulations!
On Windows: To see debug messages, install the serial driver. (Note: this should be done already on the NXP laptops provided for FTF labs)
Debug messages: We can talk to the board via a serial port, but you might need some software. Read this doc and install required software (like PuTTY or Tera Term on Windows). (Note: NXP laptops have Tera Term 4.83 pre-installed)
Locally: If you like things locally, you can do so by exporting to a supported toolchain.
I very much recommend to just use the online IDE, as it makes it easier for us, but if you want to continue hacking in the future, this is a nice way.
Program1_Blinky¶
- First we need to set up our project and our target. In a new browser window, open https://developer.mbed.org/platforms/Seeed-Arch-Link/ and click the Add to your mbed Compiler button.
- Go back to the compiler browser window and click F5 to refresh the page.
- Click the Import button, then click "Click Here to import from URL"
- Paste the URL https://developer.mbed.org/teams/Robotics-Kit-Workshop/code/Program1_Blinky/
- Double click to open main.cpp
- We need to implement a function that will blink the LED.
Under ' YOUR CODE HERE : turn on the LED' add the following code
myled = 0
- Now press Compile
- A file downloads (Program1_Blinky.bin)
- Drag the file to the 'MBED' disk
- The red LED on the board will flash.
- After flashing, hit the 'Reset' button to start the program.
- Program1_Blinky runs!
Optional: We use Ticker to periodically run the blinky function. You could also use TimeOut to run a function after a specified delay.
Program2_TempAndHumidity¶
- Now import https://developer.mbed.org/teams/Robotics-Kit-Workshop/code/Program2_TempAndHumidity/
- Open main.cpp
- We have the examples for reading temperature in CELCIUS
- Now let’s write similar code for getting the temperature in FARENHEIT and KELVIN
- Under ' YOUR CODE HERE: read the temperature in FARENHEIT and KELVIN ' add the following code
f = sensor.ReadTemperature(FARENHEIT); k = sensor.ReadTemperature(KELVIN);
- Hit the Compile button and flash the application.
- With the program running successfully, we can see the temperature and humidity information printed on the terminal (here Tera term is used for example)
Program3_Servo¶
- Now import https://developer.mbed.org/teams/Robotics-Kit-Workshop/code/Program3_Servo/
- Here we try to present you how to control the Servo
- Under ' YOUR CODE HERE: start the Servo' add the following code
myservo = p;
- Build and flash, after resetting the board you will see that
Program4_ServoWithTempAndHumidity¶
- Now import https://developer.mbed.org/teams/Robotics-Kit-Workshop/code/Program4_ServoWithTempAndHumidity/
- Under ' YOUR CODE HERE: get the status of the sensor checksum, successful or failed ' add the following code:
status = sensor.sample();
- Build and flash, after resetting the board you will see that