-
-
Save takumus/fe2356c0c250be90f0cc05bc1904a141 to your computer and use it in GitHub Desktop.
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
#include <Arduino.h> | |
const int IN1 = 9; | |
const int IN2 = 10; | |
const int IN3 = 11; | |
const int IN4 = 12; | |
int d_hs[8] = { | |
B1000, | |
B1100, | |
B0100, | |
B0110, | |
B0010, | |
B0011, | |
B0001, | |
B1001 | |
}; | |
int i = 0; | |
void step(int d); | |
void setup() | |
{ | |
pinMode(IN1, OUTPUT); | |
pinMode(IN2, OUTPUT); | |
pinMode(IN3, OUTPUT); | |
pinMode(IN4, OUTPUT); | |
} | |
void loop() | |
{ | |
step(1); | |
delayMicroseconds(900); | |
} | |
void step(int d) | |
{ | |
i += d; | |
if(i > 7) i = 0; | |
if(i < 0) i = 7; | |
byte b = d_hs[i]; | |
digitalWrite(IN1, bitRead(b, 0)); | |
digitalWrite(IN2, bitRead(b, 1)); | |
digitalWrite(IN3, bitRead(b, 2)); | |
digitalWrite(IN4, bitRead(b, 3)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment