Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
//https://aleksandarhaber.com/incremental-rotary-encoders-with-raspberry-pi-lpd3806-600bm/ /*This project depends on the now depreciated wiring pi project * wget https://project-downloads.drogon.net/wiringpi-latest.deb * or a working version is also saved the the nanocluster server * g++ -Wall -o "%e" "%f" -lwiringPi -lwiringPiDev * */ #include
#include
#include
using namespace std; long encoder0; long encoder1; int stateA=0; int stateB=0; int angle0=0; int angle1=0; int OldAngle0=0; int OldAngle1=0; //File dataFile; string dataString = ""; //hardware IO //may require "gpio mode
in" /*Encoders*/ int wireA=0; //BCM 17 int wireB=2; //BCM 27 int wireC=12; //MOSI int wireD=13; //MISO /*Buttons*/ const int buttonAB = 7; //GPIO7 A-B-encoder pin7 "gpio mode 7 in" const int buttonCD = 21; //GPIO21 (SCLK) C-D encoder "gpio mode 21 in" void A(); void B(); void C(); void D(); void setup(); //sets up hardware may do all setup including fileIO in teh future void resetImg(); //sets data in svg poly line to zero int main(){ setup(); while(1){ angle0=encoder0; angle1=encoder1; if (digitalRead(buttonAB) == LOW) { cout << "Deleting image data\n"; dataString=""; delay(100); } if (digitalRead(buttonCD) == LOW) { cout << dataString <<"\n"; delay(100); } if (angle0==OldAngle0 && angle1==OldAngle1){ ; //dont do shit if its not changing }else{ dataString += ", "; dataString += to_string(angle0); dataString += ", "; dataString += to_string(angle1); OldAngle0=angle0; OldAngle1=angle1; cout<<"Angle is:"<
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)