新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > AVR單片機(jī)控制舵機(jī)

AVR單片機(jī)控制舵機(jī)

作者: 時(shí)間:2012-08-02 來源:網(wǎng)絡(luò) 收藏
#include iom32v.h>typedef struct BYTE_BIT{unsigned BIT0:1;unsigned BIT1:1;unsigned BIT2:1;unsigned BIT3:1;unsigned BIT4:1;unsigned BIT5:1;unsigned BIT6:1;unsigned BIT7:1;}BYTEBIT;#define SET_BIT8_FORMAT(Addr)     (*((volatile BYTEBIT *)Addr)) # define PORTB_BIT     SET_BIT8_FORMAT(PORTB)# define _PB0        PORTB_BIT.BIT0# define _PB1        PORTB_BIT.BIT1# define _PB2        PORTB_BIT.BIT2# define _PB3        PORTB_BIT.BIT3# define _PB4        PORTB_BIT.BIT4# define _PB5        PORTB_BIT.BIT5# define _PB6        PORTB_BIT.BIT6# define _PB7        PORTB_BIT.BIT7/*delay(1)延時(shí)時(shí)間為300USdelay(80)延時(shí)時(shí)間為20mSdelay(4)延時(shí)時(shí)間為1mSdelay(8)延時(shí)時(shí)間為2mSdelay(6)延時(shí)時(shí)間為1.55mSdelay(2)延時(shí)時(shí)間為0.55MSdelay(10)延時(shí)時(shí)間為2.5mS*/void Delay(int j){     int i;for(;j>0;j--){ for(i=0;i35;i++);}}void main(void) {int i,j;DDRB=0XFF;while(1){//2.0ms   135度位置_PB7=1;Delay(8);_PB7=0;Delay(74);/*//1.0ms   45度位置_PB7=1;Delay(4);_PB7=0;Delay(78);//1.5ms   90度位置_PB7=1;Delay(6);_PB7=0;Delay(78);// 2.5ms   180度位置_PB7=1;Delay(10);_PB7=0;Delay(72);//0.5ms         0度位置_PB7=1;Delay(2);_PB7=0;Delay(78);*/}}

pwm相關(guān)文章:pwm是什么


51單片機(jī)相關(guān)文章:51單片機(jī)教程


單片機(jī)相關(guān)文章:單片機(jī)教程


單片機(jī)相關(guān)文章:單片機(jī)視頻教程


單片機(jī)相關(guān)文章:單片機(jī)工作原理



上一頁 1 2 下一頁

關(guān)鍵詞: AVR單片機(jī) 控制舵機(jī) 信號(hào)調(diào)制

評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉