Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //this is my example for Amperka L298P shield
- //this code placed on Pastebin
- #define RH_ENCODER_A 4 //specially not interrupt pins
- #define RH_ENCODER_B 5
- bool A = 0;
- bool new_A = 0;
- bool new_B = 0;
- void setup() {
- pinMode(RH_ENCODER_A, INPUT);
- pinMode(RH_ENCODER_B, INPUT);
- Serial.begin(9600);
- }
- void loop() {
- new_A = digitalRead(RH_ENCODER_A);
- new_B = digitalRead(RH_ENCODER_B);
- if (A != new_A) {
- Serial.print("port A = ");
- Serial.println(new_A);
- Serial.print("port B = ");
- Serial.println(new_B);
- Serial.println();
- A = new_A;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment