久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 6820|回復(fù): 9
收起左側(cè)

基于stm32的教室照明智能控制系統(tǒng)源程序與Proteus仿真

  [復(fù)制鏈接]
ID:511094 發(fā)表于 2021-3-19 22:17 | 顯示全部樓層 |閱讀模式
沒人,燈滅 1-3人,亮3個(gè)燈 4-6人亮6個(gè)燈 大于6人,全亮 液晶顯示屏,顯示人數(shù)

教室照明智能控制系統(tǒng)仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
]BF5M{NA@4SUS2CD$L65T.png 51hei.png

單片機(jī)源程序如下:
  1. #include "stm32f10x.h"
  2. #include "bsp-lcd1602.h"
  3. #include "delay.h"
  4. #include "sys.h"
  5. #include "adc.h"

  6. char people_ADD = 0;

  7. void led( void )
  8. {
  9.         GPIO_InitTypeDef GPIO_InitStructure;         
  10.         
  11.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
  12.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11;
  13.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  14.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
  15.         GPIO_Init(GPIOC, &GPIO_InitStructure);        
  16.         
  17. }

  18. void led_one( void )
  19. {
  20.         GPIO_SetBits(GPIOC,GPIO_Pin_0);
  21.         GPIO_ResetBits(GPIOC,GPIO_Pin_1);
  22.         GPIO_SetBits(GPIOC,GPIO_Pin_2);
  23.         GPIO_SetBits(GPIOC,GPIO_Pin_3);
  24.         GPIO_ResetBits(GPIOC,GPIO_Pin_4);
  25.         GPIO_SetBits(GPIOC,GPIO_Pin_5);
  26.         GPIO_SetBits(GPIOC,GPIO_Pin_6);
  27.         GPIO_ResetBits(GPIOC,GPIO_Pin_7);
  28.         GPIO_SetBits(GPIOC,GPIO_Pin_8);
  29.         GPIO_SetBits(GPIOC,GPIO_Pin_9);
  30.         GPIO_SetBits(GPIOC,GPIO_Pin_10);
  31.         GPIO_SetBits(GPIOC,GPIO_Pin_11);

  32. }

  33. void led_two(void)
  34. {
  35.         GPIO_SetBits(GPIOC,GPIO_Pin_0);
  36.         GPIO_ResetBits(GPIOC,GPIO_Pin_1);
  37.         GPIO_ResetBits(GPIOC,GPIO_Pin_2);
  38.         GPIO_SetBits(GPIOC,GPIO_Pin_3);
  39.         GPIO_ResetBits(GPIOC,GPIO_Pin_4);
  40.         GPIO_ResetBits(GPIOC,GPIO_Pin_5);
  41.         GPIO_SetBits(GPIOC,GPIO_Pin_6);
  42.         GPIO_ResetBits(GPIOC,GPIO_Pin_7);
  43.         GPIO_ResetBits(GPIOC,GPIO_Pin_8);
  44.         GPIO_SetBits(GPIOC,GPIO_Pin_9);
  45.         GPIO_SetBits(GPIOC,GPIO_Pin_10);
  46.         GPIO_SetBits(GPIOC,GPIO_Pin_11);
  47. }

  48. void led_three(void)
  49. {
  50.         GPIO_ResetBits(GPIOC,GPIO_Pin_0);
  51.         GPIO_ResetBits(GPIOC,GPIO_Pin_1);
  52.         GPIO_ResetBits(GPIOC,GPIO_Pin_2);
  53.         GPIO_ResetBits(GPIOC,GPIO_Pin_3);
  54.         GPIO_ResetBits(GPIOC,GPIO_Pin_4);
  55.         GPIO_ResetBits(GPIOC,GPIO_Pin_5);
  56.         GPIO_ResetBits(GPIOC,GPIO_Pin_6);
  57.         GPIO_ResetBits(GPIOC,GPIO_Pin_7);
  58.         GPIO_ResetBits(GPIOC,GPIO_Pin_8);
  59.         GPIO_ResetBits(GPIOC,GPIO_Pin_9);
  60.         GPIO_ResetBits(GPIOC,GPIO_Pin_10);
  61.         GPIO_ResetBits(GPIOC,GPIO_Pin_11);
  62. }

  63. void led_Down(void)
  64. {
  65.         GPIO_SetBits(GPIOC,GPIO_Pin_0);
  66.         GPIO_SetBits(GPIOC,GPIO_Pin_1);
  67.         GPIO_SetBits(GPIOC,GPIO_Pin_2);
  68.         GPIO_SetBits(GPIOC,GPIO_Pin_3);
  69.         GPIO_SetBits(GPIOC,GPIO_Pin_4);
  70.         GPIO_SetBits(GPIOC,GPIO_Pin_5);
  71.         GPIO_SetBits(GPIOC,GPIO_Pin_6);
  72.         GPIO_SetBits(GPIOC,GPIO_Pin_7);
  73.         GPIO_SetBits(GPIOC,GPIO_Pin_8);
  74.         GPIO_SetBits(GPIOC,GPIO_Pin_9);
  75.         GPIO_SetBits(GPIOC,GPIO_Pin_10);
  76.         GPIO_SetBits(GPIOC,GPIO_Pin_11);
  77.         
  78. }



  79. void Key_GPIO_Config(void)
  80. {
  81.         GPIO_InitTypeDef GPIO_InitStructure;
  82.         
  83.         /*開啟按鍵端口(PA)的時(shí)鐘*/
  84.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOC,ENABLE);
  85.         
  86.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  87.         
  88.         // IO 口做輸入口時(shí),不用設(shè)置輸出頻率
  89.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
  90.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
  91.         
  92.         GPIO_Init(GPIOA, &GPIO_InitStructure);
  93. }


  94. void KEY_Scan( void )
  95. {
  96.         if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 1 )  
  97.         {         
  98.                 /*等待按鍵釋放 */
  99.                 while(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) == 1);
  100.                 people_ADD++;
  101.                 if( people_ADD > 50 )
  102.                 {
  103.                         people_ADD = 50;
  104.                 }
  105.         }
  106.         
  107.         if( ADC_GetConversionValue(ADC1) > 1000 )
  108.         {
  109.                 while( (ADC_GetConversionValue(ADC1) > 1000 ));
  110.                 people_ADD--;
  111.                 if( people_ADD <= 0 )
  112.                 {
  113.                         people_ADD = 0;
  114.                 }
  115.         }
  116. }



  117. int main(void)
  118. {
  119.         Key_GPIO_Config();
  120.         ADC1_GPIO_Config();
  121.         ADC_Config();
  122.         LCD1602_Init();
  123.         led();
  124.         LCD1602_ShowStr(0,0,"     Light     ",15);
  125.         LCD1602_ShowStr(0,1,"People:",7);
  126.         led_Down();
  127.         
  128.         while(1)
  129.         {
  130.                 LCD1602_WriteCmd( 0x80+0x40+8);
  131.                 LCD1602_WriteDat( people_ADD/10+'0' );
  132.                 LCD1602_WriteDat( people_ADD%10+'0' );
  133.                 KEY_Scan();
  134.                
  135.                
  136.                 if(( people_ADD > 0 )&&( people_ADD <= 3 ))
  137.                 {
  138.                         led_one();
  139.                 }
  140.                 else
  141.                 {
  142.                         if(( people_ADD > 3 )&&( people_ADD <= 6 ))
  143.                         {
  144.                                 led_two();
  145.                         }
  146.                         else
  147.                         {
  148.                                 if( people_ADD > 6 )
  149.                                 {
  150.                                         led_three();
  151.                                 }
  152.                                 else
  153.                                 {
  154.                                         led_Down();
  155.                                 }
  156.                         }
  157.                 }
  158.         }
  159. }
復(fù)制代碼

所有資料51hei提供下載:
proteus仿真圖.rar (106.25 KB, 下載次數(shù): 240)

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

ID:896812 發(fā)表于 2021-6-7 10:49 | 顯示全部樓層
不錯(cuò)不錯(cuò),完整的,贊!用Keil5編譯成功了
51hei.png
51hei.png
回復(fù)

使用道具 舉報(bào)

ID:931684 發(fā)表于 2021-6-8 16:10 來自手機(jī) | 顯示全部樓層
完整的?有沒有運(yùn)行出錯(cuò)?
回復(fù)

使用道具 舉報(bào)

ID:931684 發(fā)表于 2021-6-8 16:33 | 顯示全部樓層
為什么我編譯失敗?是我的Keil設(shè)置有問題吧,都是這些頭文件找不到

Build target 'Target 1'
compiling s1.c...
s1.c(1): warning C318: can't open file 'stm32f10x.h'
s1.c(2): warning C318: can't open file 'bsp-lcd1602.h'
s1.c(3): warning C318: can't open file 'delay.h'
s1.c(4): warning C318: can't open file 'sys.h'
s1.c(5): warning C318: can't open file 'adc.h'
S1.C(11): error C202: 'GPIO_InitTypeDef': undefined identifier
S1.C(11): error C141: syntax error near 'GPIO_InitStructure'
S1.C(13): error C202: 'RCC_APB2Periph_GPIOC': undefined identifier
S1.C(17): error C202: 'GPIOC': undefined identifier
S1.C(23): error C202: 'GPIOC': undefined identifier
S1.C(24): error C202: 'GPIOC': undefined identifier
S1.C(25): error C202: 'GPIOC': undefined identifier
S1.C(26): error C202: 'GPIOC': undefined identifier
S1.C(27): error C202: 'GPIOC': undefined identifier
S1.C(28): error C202: 'GPIOC': undefined identifier
S1.C(29): error C202: 'GPIOC': undefined identifier
S1.C(30): error C202: 'GPIOC': undefined identifier
S1.C(31): error C202: 'GPIOC': undefined identifier
S1.C(32): error C202: 'GPIOC': undefined identifier
S1.C(33): error C202: 'GPIOC': undefined identifier
S1.C(34): error C202: 'GPIOC': undefined identifier
S1.C(40): error C202: 'GPIOC': undefined identifier
S1.C(41): error C202: 'GPIOC': undefined identifier
S1.C(42): error C202: 'GPIOC': undefined identifier
S1.C(43): error C202: 'GPIOC': undefined identifier
S1.C(44): error C202: 'GPIOC': undefined identifier
S1.C(45): error C202: 'GPIOC': undefined identifier
S1.C(46): error C202: 'GPIOC': undefined identifier
S1.C(47): error C202: 'GPIOC': undefined identifier
S1.C(48): error C202: 'GPIOC': undefined identifier
S1.C(49): error C202: 'GPIOC': undefined identifier
S1.C(50): error C202: 'GPIOC': undefined identifier
S1.C(51): error C202: 'GPIOC': undefined identifier
S1.C(56): error C202: 'GPIOC': undefined identifier
S1.C(57): error C202: 'GPIOC': undefined identifier
S1.C(58): error C202: 'GPIOC': undefined identifier
S1.C(59): error C202: 'GPIOC': undefined identifier
S1.C(60): error C202: 'GPIOC': undefined identifier
S1.C(61): error C202: 'GPIOC': undefined identifier
S1.C(62): error C202: 'GPIOC': undefined identifier
S1.C(63): error C202: 'GPIOC': undefined identifier
S1.C(64): error C202: 'GPIOC': undefined identifier
S1.C(65): error C202: 'GPIOC': undefined identifier
S1.C(66): error C202: 'GPIOC': undefined identifier
S1.C(67): error C202: 'GPIOC': undefined identifier
S1.C(72): error C202: 'GPIOC': undefined identifier
S1.C(73): error C202: 'GPIOC': undefined identifier
S1.C(74): error C202: 'GPIOC': undefined identifier
S1.C(75): error C202: 'GPIOC': undefined identifier
S1.C(76): error C202: 'GPIOC': undefined identifier
S1.C(77): error C202: 'GPIOC': undefined identifier
S1.C(78): error C202: 'GPIOC': undefined identifier
S1.C(79): error C202: 'GPIOC': undefined identifier
S1.C(80): error C202: 'GPIOC': undefined identifier
S1.C(81): error C202: 'GPIOC': undefined identifier
S1.C(82): error C202: 'GPIOC': undefined identifier
S1.C(83): error C202: 'GPIOC': undefined identifier
S1.C(91): error C202: 'GPIO_InitTypeDef': undefined identifier
S1.C(91): error C141: syntax error near 'GPIO_InitStructure'
S1.C(94): error C202: 'RCC_APB2Periph_GPIOA': undefined identifier
S1.C(102): error C202: 'GPIOA': undefined identifier
S1.C(108): error C202: 'GPIOA': undefined identifier
S1.C(111): error C202: 'GPIOA': undefined identifier
S1.C(119): error C202: 'ADC1': undefined identifier
S1.C(121): error C202: 'ADC1': undefined identifier
好多這個(gè)
回復(fù)

使用道具 舉報(bào)

ID:336378 發(fā)表于 2021-6-16 09:49 | 顯示全部樓層
樓上需要安裝 KEIL   MDK  軟件
回復(fù)

使用道具 舉報(bào)

ID:933572 發(fā)表于 2021-6-19 23:11 | 顯示全部樓層
工程在哪個(gè)文件夾里面 大家能告知一下嗎?
回復(fù)

使用道具 舉報(bào)

ID:928738 發(fā)表于 2021-6-20 12:29 | 顯示全部樓層
請(qǐng)問proteus用的哪個(gè)版本?是不是有版本限制?
回復(fù)

使用道具 舉報(bào)

ID:387687 發(fā)表于 2021-12-7 17:35 | 顯示全部樓層

請(qǐng)問proteus用的哪個(gè)版本?
回復(fù)

使用道具 舉報(bào)

ID:1029323 發(fā)表于 2022-5-31 16:59 | 顯示全部樓層
無心法師III 發(fā)表于 2021-6-8 16:10
完整的?有沒有運(yùn)行出錯(cuò)?

我的仿真軟件運(yùn)行不正常
回復(fù)

使用道具 舉報(bào)

ID:1027059 發(fā)表于 2022-6-4 09:37 | 顯示全部樓層
xjj850205 發(fā)表于 2021-12-7 17:35
請(qǐng)問proteus用的哪個(gè)版本?

一般都是高版本兼容性更好一點(diǎn)
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 精品久久久久久国产 | 成人久久18免费网站麻豆 | 精品91av| 久草视频在线播放 | 中文字幕av网 | 亚洲男人天堂 | 天天拍夜夜爽 | 午夜伊人| 久久综合久久自在自线精品自 | 亚洲精品99 | 国产精品日韩欧美一区二区三区 | 亚州中文 | 人人做人人澡人人爽欧美 | 亚洲欧美视频一区 | 99精品久久久久久中文字幕 | 草久在线 | 亚洲欧美中文日韩在线v日本 | 国产精品一区免费 | 中国一级大毛片 | 天堂综合| 日本午夜在线视频 | 久久久精品国产 | 久久精品一二三影院 | 国产精品亚洲一区二区三区在线 | 久久婷婷国产麻豆91 | av天天干 | 美女久久 | 欧美日韩在线视频一区 | 久久久久成人精品免费播放动漫 | 日韩在线精品视频 | 成人在线视频网 | 国产精品视频yy9299一区 | 久久人操 | 亚洲成av人片在线观看 | 精品国产欧美一区二区三区成人 | 亚洲精品视频免费 | 黄色一级大片视频 | 国产中文字幕在线观看 | 一区二区三区不卡视频 | 亚洲欧美成人影院 | 伊人影院在线观看 |