Skip to Main Content
It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.

Robots @ SIT

Get hold of one of the available Robots at SIT Library and start your robotics journey today!

Description

Required Knowledge:

Conditional statements, Logical operators, Loops, Variables, Accelerometer, Multiple Finches

Application:

Accelerometers are essential in aircraft and missiles in determining their orientation relative to the curve of the Earth. It is also used in fall detection devices, as well as in mobile devices to change the orientation of the screen display according to how the user tilts the device.

 

Remote Control Finch

Use the accelerometer on one Finch to control the movements of the other Finch in a more complex and complete way. Using the accelerometer measurements on the "remote control", the Finch can move in any direction (e.g. forwards and left, backwards and right) depending on how the user tilts the "remote control".

 

Use a while loop (Python) or forever loop block (Snap!) to print the acceleration values constantly to the screen, using "print(bird.getAcceleration())" (Python) or say blocks with the Finch Accelerometer blocks (Snap!). Observe these values and note what positions will give certain acceleration values. (Hint: Observe the x and y acceleration values)

 

Snap!:

1. Finch A will refer to the "remote control" and Finch B will be the moving Finch.

2. Use a repeat until block that stops when button A on Finch A is pressed. Steps 3, 5 and 6 will be written in this loop.

3. Create two variables ax and ay. Set them to the following values:

4. Use a couple of if blocks that trigger depending on the position of Finch A, with the corresponding Finch B wheel speeds inside each if block. (Hint: There should be 7 if blocks)

5. When the repeat until block stops, add a Finch 'B' stop block for Finch B to stop its motion.

 

Python:

1. In your code, bird1 will refer to the "remote control" and bird2 will refer to the moving Finch.

2. Use a while loop that breaks when button A is pressed on bird1. Steps 3 to 5 will be written in this loop.

3. Use the "accelX, accelY, accelZ = bird1.getAcceleration()" statement to obtain the accelerometer values from bird1.

4. Declare two variables ax and ay, where ax = int(5*float(accelX)) and ay = int(5*float(accelY)). Play around with the '5' value and adjust according to the wheel power you desire.

5. Use a if-elif-else statement with a bunch of elif statements to account for all the possible positions of bird1 and the corresponding wheel speeds of bird2. (Hint: There are a total of 7 possible positions)

6. Do not forget to add a "bird2.stop()" statement when the while loop breaks to stop bird2's motion.

Sample Codes