Coder Social home page Coder Social logo

shiftpwm's Introduction

ShiftPWM

ShiftPWM is a library/class for Arduino (tested on ESP32 only) to generate a PWM signal over a shift register (74HC595)

How to use:

  • copy ShiftPWM.h and ShiftPWM.cpp in the same folder of your program
  • add include "ShiftPWM.h"
  • Create instance of ShiftPWM by specifying duty cycles in Duties struct (can be updated later)
  • Create a timer (preferably 1MHz), in its handler call ShiftPWM::Calculate() which returns a byte
  • Write the byte returned from Calculate() to the shift register
  • [ESP] To make timer creation simpler include ESPTimerHelper.h then call StartTimer(SetTimer(TIMER_INDEX,TIMER_HANDLER))

Update:

The class doesn't write the value to shift register anymore but returns a value, this is done to make it compatible with other environments (the ones that don't have pinMode, digtalWrite...etc)

shiftpwm's People

Contributors

cobrce avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

shiftpwm's Issues

Esp32 Error

Error with ESP32

1- Using "example.ino"
2- Checking code (before compiling)
3- Error:

In file included from C:\Users\Tiago\AppData\Local\Temp\arduino_modified_sketch_857920\example.ino:6:0:

C:\Users\Tiago\Documents\Arduino\libraries\ShiftPWM-master/ESPTimerHelper.h:5:17: error: variable or field 'StartTimer' declared void

 void StartTimer(hw_timer_t * timer);

                 ^

C:\Users\Tiago\Documents\Arduino\libraries\ShiftPWM-master/ESPTimerHelper.h:5:17: error: 'hw_timer_t' was not declared in this scope

C:\Users\Tiago\Documents\Arduino\libraries\ShiftPWM-master/ESPTimerHelper.h:5:30: error: 'timer' was not declared in this scope

 void StartTimer(hw_timer_t * timer);

                              ^

C:\Users\Tiago\Documents\Arduino\libraries\ShiftPWM-master/ESPTimerHelper.h:6:1: error: 'hw_timer_t' does not name a type

 hw_timer_t * SetTimer(int timer,void(*callback)(),int periode_us = 10);

 ^

C:\Users\Tiago\AppData\Local\Temp\arduino_modified_sketch_857920\example.ino: In function 'void InitPWMTimer()':

example:33:58: error: 'SetTimer' was not declared in this scope

 void InitPWMTimer() { StartTimer(SetTimer(0, TimerHandler)); }

                                                          ^

example:33:59: error: 'StartTimer' was not declared in this scope

 void InitPWMTimer() { StartTimer(SetTimer(0, TimerHandler)); }

                                                           ^

C:\Users\Tiago\AppData\Local\Temp\arduino_modified_sketch_857920\example.ino: In function 'void InitDutyChangeTimer()':

example:53:57: error: 'SetTimer' was not declared in this scope

     StartTimer(SetTimer(1, DutyChangeTimerHandler, 10000));

                                                         ^

example:53:58: error: 'StartTimer' was not declared in this scope

     StartTimer(SetTimer(1, DutyChangeTimerHandler, 10000));

                                                          ^

exit status 1
'SetTimer' was not declared in this scope

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.