Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Wire.h>
- #include "TimerOne.h"
- int i = 0;
- int count = 0;
- int lowspeed = 1000;
- int MSsteps[5] = {7,6,2,4,0};
- void callback1();
- void setup()
- {
- DDRB = 0xFF; // pin 8 for dir, pin 9 for timer
- DDRD = 0xF4; // pin 2 to 4 are for MS#
- PORTB = 0; // want MS# to be 0s
- PORTD = 0; // want dir and timer 0
- //pinMode(5, OUTPUT);
- //pinMode(6, OUTPUT);
- //pinMode(2, OUTPUT);
- //pinMode(3, OUTPUT);
- //digitalWrite(3,LOW);
- //digitalWrite(2,HIGH);
- //Timer0.initialize(10000000);
- Timer1.initialize(10000);
- TCCR1A |= _BV(COM1A0);
- TCCR1B |= _BV(WGM12);
- //Timer1.attachInterrupt(callback1);
- Serial.begin(19200);
- }
- void callback1()
- {
- if(count == lowspeed)
- {
- PORTD ^= 0x8;
- count=0;
- }
- else
- count++;
- }
- void loop()
- {
- i = 1;
- //for(i = 0; i <=4; i++)
- {
- PORTD &= 0xE3; // resets MS# to 0;
- PORTD |= (MSsteps[i] << 2);
- Serial.print("PORTD is ");
- Serial.println(PORTD,BIN);
- delay(5000);
- }
- }
Add Comment
Please, Sign In to add comment