zoukankan      html  css  js  c++  java
  • Ardiono入门实践之LED彩灯

    int redPin = 7;
    int greenPin = 9;
    int bluePin = 11;
    
    void setup() {
      // put your setup code here, to run once:
      pinMode(redPin,OUTPUT);
      pinMode(greenPin,OUTPUT);
      pinMode(bluePin,OUTPUT);
    }
    
    void setcolor(int red,int green,int blue)
    {
      if(red == true)
      {
        digitalWrite (redPin,HIGH);
        delay(1000);
        
      }
      else
      {
        digitalWrite(redPin,LOW);
      }
      if(green == true)
      {
        digitalWrite(greenPin,HIGH);
        delay(1000);
       
      }
      else
      {
        digitalWrite(greenPin,LOW);
      }
      if(blue == true)
      {
        digitalWrite(bluePin,HIGH);
        delay(1000);
       
      }
      else
      {
        digitalWrite(bluePin,LOW);
      }
      
    }
    
    
    void loop() {
      // put your main code here, to run repeatedly:
      while(1)
      { 
        setcolor(true,false,false);
        setcolor(true,true,false);
        setcolor(false,false,false);
        setcolor(true,true,true);
        setcolor(false,true,true);
        setcolor(false,true,false);
        setcolor(false,false,false);
        
      }
      
    }
  • 相关阅读:
    python函数及模块
    Python分支结构及循环结构
    python基本的知识
    11.21学习总结
    进度日报28
    进度日报27
    进度日报26
    进度日报25
    进度日报24
    11.14学习总结
  • 原文地址:https://www.cnblogs.com/zhongllmm/p/14044543.html
Copyright © 2011-2022 走看看