Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int encoder_position = 0;
- int pozitie_motor = 0;
- void setup() {
- Serial.begin(9600);
- DDRD = DDRD | B00000000; // this is safer as it sets pins 2 to 7 as outputs
- attachInterrupt(digitalPinToInterrupt(3), encoder, RISING);
- //detachInterrupt(digitalPinToInterrupt(3))
- }
- void automat()
- {
- // state 10 { pozite motor = 1200;
- }
- void loop() {
- // put your main code here, to run repeatedly:
- Serial.println(encoder_position);
- }
- void encoder()
- {
- if ((PIND & B00000100) == 4)
- {
- encoder_position++;
- }
- else
- {
- encoder_position--;
- }
- if (encoder_positon == pozitie_motor)
- {
- // stop releu
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement