Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Servo extends InputPort
- {
- type = "float";
- pin = null;
- // define a constructor so that we can construct seperate instances for servos 1 and 2
- constructor(name, pin) {
- // call through to the base (InputPort) constructor with the provided name
- base.constructor(name)
- this.pin = pin
- // no need to configure the pins as we've already done it at global scope
- }
- function set(value)
- {
- // Display on our Planner node
- server.show(pin + "=" + value);
- pin.configure(PWM_OUT, 0.000870, value);
- }
- }
- imp.configure("PWM Test", [Servo("Channel1", hardware.pin1), Servo("Channel2", hardware.pin2)], []);
- // Display our message
- server.connect();
- server.show("PWM Test Started!");
- server.log("PWM Test Started");
- // Setup I/O
- hardware.pin1.configure(PWM_OUT, 0.000870, 0.0);
- hardware.pin2.configure(DIGITAL_OUT);
- hardware.pin2.write(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement