这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 企业专区 » Renesas » 散步的鱼的进程帖

共21条 2/3 1 2 3 跳转至
助工
2012-12-31 22:30:10     打赏
11楼
请假两个礼拜!期末考试

助工
2013-01-07 17:38:35     打赏
12楼
预祝考试成功

助工
2013-01-18 20:18:42     打赏
13楼

红外人体感应模块:

实体图:

源代码:

/*GR-SAKURA Sketch Template Version: V1.01*/
#include 

#define INTERVAL 100

void setup()
{
    pinMode(PIN_LED0,OUTPUT);
    pinMode(PIN_LED1,OUTPUT);
    pinMode(PIN_P22,INPUT);
}

void loop()
{
 while(1)
 {
  if(digitalRead(PIN_P22) != 0x01)
    {
    digitalWrite(PIN_LED0, 1);
    delay(INTERVAL);
    digitalWrite(PIN_LED0, 0);
    delay(INTERVAL);
     }
   else
    {
    digitalWrite(PIN_LED1, 1);
    delay(INTERVAL);
    digitalWrite(PIN_LED1, 0);
    delay(INTERVAL);
    }
  }
}
下面是人体红外感应模块外接示意图:

人体红外感应模块工作原理:当有人进入其感应范围则输入高电平,人离开感应范围则自动延时关闭高电平并输出低电平。我用板子P22引脚接收红外模块发出的感应信号。


助工
2013-01-22 21:04:25     打赏
14楼



 Sakura板--收音机模块



#include
#include


#define uchar unsigned char
#define uint unsigned int

uchar radio_write_data[5] = {0x29,0xc2,0x20,0x11,0x00};//要写入TEA5767的数据
uint radio_read_data[5];

uint pll = 0x29c2;    //默认电台的pll=87.8MHZ
uint max_pll = 0x339b;            //108MHz时的pll,
uint min_pll = 9000;            //70MHz时的pll
uint max_freq = 1000;
uint min_freq = 0;
uint frequency;

int get_pll();
int get_frequency();
void radio_write()
{
   uchar i;
   Wire.begin();
   Wire.write(0xc0);//TEA5767写地址
   while(!Wire.available())
   {
     for(i = 0;i < 5;i++)
     {
       Wire.beginTransmission(0);
       Wire.write(radio_write_data[i]);
     }
   }
  Wire.endTransmission();
}
void radio_read()
{
    uchar i;
    uchar temp_l,temp_h;
    uchar pll = 0;
    Wire.begin();
    Wire.write(0xc1);        //TEA5767读地址
    if(!Wire.available())
    {
        for(i=0;i<5;i++)
        {
            Wire.beginTransmission(0);
            radio_read_data[i] = Wire.read();
        }
    }
    Wire.endTransmission();
    temp_l=radio_read_data[1];
    temp_h=radio_read_data[0];
    temp_h&=0x3f;
    pll=temp_h*256+temp_l;
    get_frequency();
}
//由频率计算PLL
int get_pll()
{
    uchar hlsi;
    uint twpll=0;
    hlsi = radio_write_data[2]&0x10;
    if (hlsi)
        pll=(unsigned int)((float)((frequency+225)*4)/(float)32.768); 

  //频率单位:kMZ
    else
        pll=(unsigned int)((float)((frequency-225)*4)/(float)32.768); 

  //频率单位:k
   return pll;
}
//由PLL计算频率
int get_frequency()
{
    unsigned char hlsi;
    unsigned int npll=0;
    npll=get_pll();
    hlsi=radio_write_data[2]&0x10;
    if (hlsi)
        frequency=(unsigned long)((float)(npll)*(float)8.192-225);   

//频率单位:KHz
    else
        frequency=(unsigned long)((float)(npll)*(float)8.192+225);   

//频率单位:KHz
    return frequency;
}
//手动设置频率,mode=1,+0.1MHz; mode=0:-0.1MHz ,不用考虑TEA5767

//用于搜台的相关位:SM,SUD
void search(char mode)
{
    int frequency1 = get_frequency();
    radio_read();      
    if(mode)
    {
        frequency+=100;
        if(frequency>max_freq)
            frequency=min_freq;
    }
    else
    {
        frequency-=100;
        if(frequency             frequency=max_freq;
    }        
    get_pll();
    radio_write_data[0]=pll/256;
    radio_write_data[1]=pll%256;
    radio_write_data[2]=0x20;
    radio_write_data[3]=0x11;
    radio_write_data[4]=0x00;
    radio_write();
}

void setup()
 {
     TwoWire ();
     Wire.begin();
     radio_write();
    radio_read();
    get_pll();
    get_frequency();
}
 void loop()
{
     while(1)
     {
       search(1);
     }
}
 


助工
2013-01-23 16:10:40     打赏
15楼

 

Sakura板--步进电机


 

#include
#include//引入步进电机库函数

Stepper step21(10,PIN_P51,5PIN_P53,PIN_P54,PIN_P5); //启动步进电机;

void setup()
{
  pinMode(PIN_P51,OUTPUT);
  pinMode(PIN_P53,OUTPUT);
  pinMode(PIN_P54,OUTPUT);
  pinMode(PIN_P55,OUTPUT);
}
void loop()
{
  step21.setSpeed(10);//设置转速
  step21.step(2);//正转
  while(1)
  {
   digitalWrite(PIN_P51,1);
   digitalWrite(PIN_P53,1);
   digitalWrite(PIN_P54,1);
   digitalWrite(PIN_P55,1);
   delay(100);  
  
   step21.step(-2);//反转
    digitalWrite(PIN_P51,1);
   digitalWrite(PIN_P53,1);
   digitalWrite(PIN_P54,1);
   digitalWrite(PIN_P55,1);
   delay(100);
  }
}


院士
2013-01-23 16:55:08     打赏
16楼
楼主的图都没有啊~~


楼主再编辑一下吧~~

院士
2013-01-23 17:03:42     打赏
17楼
楼主,给你电话都不接啊

助工
2013-01-30 23:43:40     打赏
18楼

 

 

温湿度模块--DHT11

 


 

#include
#include
                                        
#define DHT11_PIN 23


byte read_dht11_dat()
{
  byte i = 0;
 byte result=0;
for(i=0; i< 8; i++) //读入数据
{
    while(!(PINC & _BV(DHT11_PIN)));    // 延时等待
   delayMicroseconds(30);
    if(PINC & _BV(DHT11_PIN))  
   result |=(1<<(7-i));
          while((PINC & _BV(DHT11_PIN)));  // 当值为“1”时停止
  }
 return result;
}
 
void setup()
{
 DDRC |= _BV(DHT11_PIN);
 PORTC |= _BV(DHT11_PIN);
 
 Serial.begin(19200); //串口波特率
 Serial.println("Ready"); //串口准备
}
 
void loop()
{
  byte dht11_dat[5];
  byte dht11_in;
  byte i;
 
  PORTC &= ~_BV(DHT11_PIN);
  delay(18);

  PORTC |= _BV(DHT11_PIN);
  delayMicroseconds(40);

  DDRC &= ~_BV(DHT11_PIN);
  delayMicroseconds(40);

  dht11_in = PINC & _BV(DHT11_PIN);
  if(dht11_in)
  {
   Serial.println("dht11 start condition 1 not met");
   return;
   }
  delayMicroseconds(80); //延时等待                                          
  dht11_in = PINC & _BV(DHT11_PIN);
  if(!dht11_in)
  {
   Serial.println("dht11 start condition 2 not met");
   return;
   }
  delayMicroseconds(80); //准备接收数据
 
  for (i=0; i<5; i++)
     dht11_dat[i] = read_dht11_dat();

  DDRC |= _BV(DHT11_PIN);
  PORTC |= _BV(DHT11_PIN);
  byte dht11_check_sum = dht11_dat[0]+dht11_dat[1]+dht11_dat[2]+dht11_dat[3];
 
 if(dht11_dat[4]!= dht11_check_sum) //检查接受结果
 {
    Serial.println("DHT11 checksum error");
 }
  Serial.print("Current humdity = ");
  Serial.print(dht11_dat[0], DEC);
  Serial.print(".");
  Serial.print(dht11_dat[1], DEC);
  Serial.print("%  ");
  Serial.print("temperature = ");
  Serial.print(dht11_dat[2], DEC);
  Serial.print(".");
  Serial.print(dht11_dat[3], DEC);
  Serial.println("C  ");
  delay(2000);

}



助工
2013-01-31 00:11:46     打赏
19楼

显示模块--迪文7寸屏


部分源代码:

#define   HEAD   0xAA //命令的帧头


#define   BLACK        0x0000    //  hei       ?  0,   0, 0
#define   NAVY         0x000F    //  shenlan   ?  0,   0, 128
#define   DGREEN       0x03E0    //  shenlv    ?  0, 128, 0
#define   DCYAN        0x03EF    //  shenqing  ?  0, 128, 128
#define   MAROON       0x7800    //  shenhong  ?128,   0, 0
#define   PURPLE       0x780F    //  zi        ?128,   0, 128
#define   OLIVE        0x7BE0    //  ganlanlv  ?128, 128, 0
#define   LGRAY        0xC618    //  huibai    ?192, 192, 192
#define   DGRAY        0x7BEF    //  shenhui   ?128, 128, 128
#define   BLUE         0x001F    //  lan       ?  0,   0, 255
#define   GREEN        0x07E0    //  lv        ?  0, 255, 0
#define   CYAN         0x07FF    //  qing      ?  0, 255, 255
#define   RED          0xF800    //  hong      ?255,   0, 0
#define   MAGENTA      0xF81F    //  pinhong   ?255,   0, 255
#define   YELLOW       0xFFE0    //  huang     ?255, 255, 0
#define   WHITE        0xFFFF    //  bai       ?255, 255, 255


// define the command
#define HMI_HANDSHAKE       0x00
#define HMI_HANDSHAKE_ACK   0x3c
#define HMI_SET_PALETTE     0x40
#define HMI_SET_SPACING     0x41
#define HMI_CURSOR          0x44
#define HMI_CLEAR           0x52
#define HMI_DISPLAY_PICTURE 0x70
#define HMI_CHAR_8x8        0x53
#define HMI_CHAR_16x16      0x54
#define HMI_CHAR_32x32      0x55
#define HMI_CHAR_12x12      0x6e
#define HMI_CHAR_24x24      0x6f
#define HMI_DISSTR_MEGA     0x98
#define HMI_BACKLIGHT_ON    0x5f
#define HMI_BACKLIGHT_OFF   0x5e




char windowtext[1];
unsigned char afwkq[27]={0xAA, 0x98, 0x01, 0x9A, 0x00, 0x6E, 0x22, 0x81, 0x02, 


0x00, 0x00, 0x00,
0x1F, 0xB0, 0xB2, 0xB7, 0xC0, 0xCE, 0xB4, 0xBF, 0xAA, 0xC6, 0xF4, 


0xCC, 0x33, 0xC3, 0x3C};
unsigned char jkz[29]={0xAA, 0x98, 0x01, 0x9A, 0x00, 0x6E, 0x22, 0x81, 0x02, 


0x00, 0x00, 0x00,
0x1F, 0xBC, 0xE0, 0xBF, 0xD8, 0xD6, 0xD0, 0x2E, 0x2E, 0x2E, 0x2E, 


0x2E, 0x2E, 0xCC, 0x33, 0xC3, 0x3C};
unsigned char jg[35]={0xAA, 0x98, 0x01, 0x9A, 0x00, 0x6E, 0x22, 0x81, 0x02, 0x00, 


0x00, 0x00, 0x1F,
0xBE, 0xAF, 0xB8, 0xE6, 0xA3, 0xA1, 0xD3, 0xD0, 0xD2, 0xEC, 0xB3, 


0xA3, 0xC7, 0xE9, 0xBF, 0xF6, 0xA3, 0xA1, 0xCC, 0x33, 0xC3, 0x3C};
unsigned char zc[21]={0xAA, 0x98, 0x01, 0x54, 0x00, 0xA0, 0x22, 0x81, 0x02, 0x00, 


0x00, 0x00, 0x1F, 0xD5, 0xFD, 0xB3, 0xA3, 0xCC, 0x33, 0xC3, 0x3C};
unsigned char cb[23]={0xAA, 0x98, 0x01, 0x54, 0x00, 0xA0, 0x22, 0x81, 0x02, 0x00, 


0x00, 0x00, 0x1F, 0xB3, 0xAC, 0xB1, 0xEA, 0xA3, 0xA1, 0xCC, 0x33, 0xC3, 0x3C};


/********************************
*  函数名称:lcdInt()
*  函数介绍: lcd初始化函数
*  入口参数: 无
*  出口参数: 无
*********************************/
void lcdInt()
{
  Serial.begin(115200);
}
/******************************************************************************
*  函数名称:lcdCommandOver()
*  函数介绍: 向LCD发送帧尾命令
*  入口参数:无
*  出口参数:无
 ******************************************************************************/
void lcdCommandOver()
{
UARTCharSend(lcdPort,0XCC);
UARTCharSend(lcdPort,0X33);
UARTCharSend(lcdPort,0XC3);
UARTCharSend(lcdPort,0X3C);
}
/******************************************************************************
*  函数名称:llcdCommandSend(unsigned char *str)
*  函数介绍: 向LCD发送命令
*  入口参数:命令指针
*  出口参数:无
 ******************************************************************************/
void lcdCommandSend(unsigned char *str)
{
lcdCommandStart();
UARTSend(lcdPort,str,strlen(str));
lcdCommandOver();
}
/******************************************************************************
*  函数名称:JumpPic(uint8 PicId)
*  函数介绍:HMI LCD图片跳转显示函数
*  入口参数:PicId为已下载进入HMI LCD的图片编号
*  出口参数:无
*  说    明:必须先下载图片
 ******************************************************************************/
void JumpPic(unsigned char PicId)
{
lcdCommandStart();
UARTCharSend(lcdPort, HMI_DISPLAY_PICTURE );
UARTCharSend(lcdPort, PicId);
lcdCommandOver();
}


助工
2013-01-31 22:14:13     打赏
20楼


 Sakura板--智能家庭管家完成


 

 

 

 

 


 

 演示视频:http://v.youku.com/v_show/id_XNTA5NDY3MDgw.html


共21条 2/3 1 2 3 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]