Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>
- #include <avr/delay.h>
- void prepare_system() {
- DDRB |= (1<<PB0);
- DDRC = 0xff;
- }
- void arm_move(int degree) {
- if (degree > 0) {
- for (int i = 0; i < degree; i++) {
- PORTC = 0x21;
- _delay_ms(4);
- PORTC = 0x20;
- _delay_ms(20);
- }
- } else if (degree < 0 ) {
- for (int i = 0; i < degree; i++) {
- PORTC = 0x10;
- _delay_ms(2);
- PORTC = 0x00;
- _delay_ms(2);
- }
- }
- }
- int main(void) {
- prepare_system();
- while (1) {
- PORTB ^= (1<<PB0);
- arm_move(60);
- _delay_ms(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement