Having fun with Seesaw

I saw this one on youtube and decided to create my own version and program it with Kotlin. It’s very easy to assemble and to program too. Here are some pictures:

Here is the code in Kotlin:

package com.kotlinrobots.seesaw

import lejos.hardware.motor.EV3LargeRegulatedMotor
import lejos.hardware.port.MotorPort

fun main(args: Array<String>) {

    val motorA = EV3LargeRegulatedMotor(MotorPort.A)
    val motorD = EV3LargeRegulatedMotor(MotorPort.D)

    for (i in 1..10) {
        Thread.sleep(1000)
        motorA.rotate(30 )
        motorA.rotate(-30 )
        Thread.sleep(1000)
        motorD.rotate(30 )
        motorD.rotate(-30 )
    }
}

Code is pretty simple, basically all we need is two motors that rotate 30 degrees in this case and then return to their original position. Physics and gravity will do the rest of the job.

Here is the video of our seesaw in action:

Source Code

Miguel

Leave a Reply

Your email address will not be published. Required fields are marked *