-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed files to correspond to library name, made the 3 LED pins optional parameters to the constructor.
- Loading branch information
Arnd
authored and
Arnd
committed
Dec 14, 2016
1 parent
2414ac6
commit 60c0ddd
Showing
3 changed files
with
26 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
/******************************************************************************************************************* | ||
** This program defines the RotaryEncoder class header. ** | ||
** This program defines the RotaryEncoder class header. It is published on GitHub and full description of the ** | ||
** class as well as the public function descriptions can be found at the GitHub wiki pages located at: ** | ||
** ** | ||
** https://github.com/SV-Zanshin/RotaryEncoder/wiki ** | ||
** ** | ||
** This program demonstrates the Rotary Encoder class which controls a commonly used rotary encoder with a clear ** | ||
** knob using 3 colored LEDs (Red, Green and Blue) along with a pushbutton. These are available from sources such ** | ||
|
@@ -24,17 +27,18 @@ | |
** ** | ||
** Vers. Date Developer Comments ** | ||
** ====== ========== =================== ======================================================================== ** | ||
** 1.0.0 2016-12-14 [email protected] Changed include from "Encoder" to "RotaryEncoder", added comments ** | ||
** 1.0.0 2016-12-13 [email protected] Initial coding ** | ||
** ** | ||
*******************************************************************************************************************/ | ||
#include <Encoder.h> // Include Encoder library // | ||
#include <RotaryEncoder.h> // Include Encoder library // | ||
//----------------------------------// | ||
const uint8_t ROTARY_PIN_1 = 2; // Pin for left rotary encoder pin // | ||
const uint8_t ROTARY_PIN_2 = 3; // Pin for right rotary encoder pin // | ||
const uint8_t PUSHBUTTON_PIN = 7; // Pin for pushbutton connector pin // | ||
const uint8_t RED_PIN = 11; // Red LED PWM pin. This is grounded// | ||
const uint8_t GREEN_PIN = 10; // Green LED PWM pin. Grounded // | ||
const uint8_t BLUE_PIN = 9; // Blue LED PWM pin. Grounded // | ||
const uint8_t RED_PIN = 11; // Red LED PWM pin. Ground = FULL // | ||
const uint8_t GREEN_PIN = 10; // Green LED PWM pin. Ground = FULL // | ||
const uint8_t BLUE_PIN = 9; // Blue LED PWM pin. Ground = FULL // | ||
//----------------------------------// | ||
EncoderClass Encoder(ROTARY_PIN_1, ROTARY_PIN_2, PUSHBUTTON_PIN, // Instantiate class defining all // | ||
RED_PIN, GREEN_PIN, BLUE_PIN); // of the pins that are used // | ||
|
@@ -43,8 +47,8 @@ void setup() { // | |
Serial.begin(115200); // Initialize Serial I/O at speed // | ||
delay(1000); // Wait 1 second for initialization // | ||
Serial.println("Starting Encoder Program..."); // // | ||
} // of method setup() //----------------------------------// | ||
|
||
} // of method setup() // // | ||
//----------------------------------// | ||
void loop(){ // Main program infinite loop // | ||
static int last = Encoder.GetEncoderValue(); // Store previous Encoder value // | ||
uint8_t presses = Encoder.GetButton(); // See how often button was pressed // | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,19 +37,20 @@ | |
** ** | ||
** Vers. Date Developer Comments ** | ||
** ====== ========== =================== ======================================================================== ** | ||
** 1.0.1 2016-12-14 [email protected] Allowed defaults for LEDs on class constructer ** | ||
** 1.0.b3 2016-12-13 [email protected] Made fading start only after the maximum setting was reached ** | ||
** 1.0.b2 2016-12-12 [email protected] Fixed interrupt calls ** | ||
** 1.0.b1 2016-12-04 [email protected] Initial coding ** | ||
** ** | ||
*******************************************************************************************************************/ | ||
#include "Arduino.h" // Arduino data type definitions // | ||
#ifndef Encoder_h // Guard code definition // | ||
#define Encoder_h // Define the name inside guard code// | ||
#ifndef RotaryEncoder_h // Guard code definition // | ||
#define RotaryEncoder_h // Define the name inside guard code// | ||
class EncoderClass { //----------------------------------// | ||
public: // Publicly visible class members // | ||
EncoderClass(const uint8_t LeftPin, const uint8_t RightPin, // Class constructor // | ||
const uint8_t PushbuttonPin, const uint8_t RedPin, // // | ||
const uint8_t GreenPin,const uint8_t BluePin); // // | ||
const uint8_t PushbuttonPin, const uint8_t RedPin=255, // // | ||
const uint8_t GreenPin=255,const uint8_t BluePin=255); // // | ||
uint8_t GetButton(); // Returns number of button pushes // | ||
int16_t GetEncoderValue(); // Return the encoder value // | ||
void SetEncoderValue(const int16_t NewValue = 0); // Set the encoder value // | ||
|