2015-04-29 01:23:45 +02:00
|
|
|
/*
|
|
|
|
|
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
|
|
|
|
* Copyright (c) 2014 Intel Corporation.
|
|
|
|
|
* Author: Jakub Kramarz <jkramarz@virtuslab.com>
|
|
|
|
|
* Copyright (c) 2015 VirtusLab
|
|
|
|
|
*
|
2019-05-09 09:47:11 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2015-04-29 01:23:45 +02:00
|
|
|
*/
|
|
|
|
|
|
2015-09-30 13:21:23 +03:00
|
|
|
import mraa.Pwm;
|
|
|
|
|
|
2015-04-29 01:23:45 +02:00
|
|
|
public class CyclePwm3 {
|
2015-09-30 13:21:23 +03:00
|
|
|
static {
|
|
|
|
|
try {
|
|
|
|
|
System.loadLibrary("mraajava");
|
|
|
|
|
} catch (UnsatisfiedLinkError e) {
|
|
|
|
|
System.err.println(
|
|
|
|
|
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
|
|
|
|
|
e);
|
|
|
|
|
System.exit(1);
|
|
|
|
|
}
|
2015-04-29 01:23:45 +02:00
|
|
|
}
|
2015-09-30 13:21:23 +03:00
|
|
|
public static void main(String argv[]) throws InterruptedException {
|
|
|
|
|
//! [Interesting]
|
|
|
|
|
Pwm pwm = new mraa.Pwm(3);
|
|
|
|
|
pwm.period_us(200);
|
|
|
|
|
pwm.enable(true);
|
2015-04-29 01:23:45 +02:00
|
|
|
|
2015-09-30 13:21:23 +03:00
|
|
|
float value = 0;
|
2017-06-05 18:22:29 +02:00
|
|
|
for (int i = 100; i > 0; --i) {
|
2015-09-30 13:21:23 +03:00
|
|
|
value += 0.01;
|
|
|
|
|
pwm.write(value);
|
|
|
|
|
Thread.sleep(50);
|
|
|
|
|
if (value >= 1) {
|
|
|
|
|
value = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//! [Interesting]
|
2015-04-29 01:23:45 +02:00
|
|
|
}
|
|
|
|
|
}
|