Giter Site home page Giter Site logo

pwmlib's Introduction

PWM

An Arduino library that deals with PWM stuff like reading from RC Receivers and writing to ESCs

A very crude example from ESC_RC example

#include <PWM.h>

ESC m1(7);      // ESC initialiazed to digital pin 7
RCRecv ch1(2);  // RCRecv initialiazed to digital pin 2

void setup(){}

void loop(){
  m1.write(max(ch1.read() - 100, 0));
}

In the code the first thing defined after including the library is the definition of an ESC object and a RCRecv object, which handle respectively controlling the ESCs speed and reading from an RC reciever.

Then for setting the ESCs speed just use the write function. For reading signal with an RCRecv, just use the read function.

Reference

void ESC::write(unsigned long t):

This function takes in an unsigned long beacause time can't be negative (unsigned) an it can be a lot (long)

void ESC::begin(unsigned long min, unsigned long max):

This function starts the calibration of the ESC an should be called while the ESC isn't connected to power. While the program's waiting for the ESC to have power, update() should be called. (For more info, check out the ESC_Calibration example).

void ESC::calibrate():

This function should be called after begin() and after the batteries haave been connected to the ESC.

void ESC::update():

This function should be called while the program is waiting and the motors should be moving. It sets the speed of the motors to the value of ESC::speed

ESC::speed:

This variable stores the value of the last set or write. It is of type unsigned long

unsigned long RCRecv::read():

This function gives out an unsigned long number for the same reason the write takes it in

pwmlib's People

Contributors

theperkinrex avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.