2019年6月3日 星期一
PWM
boolean pushBtn1;
boolean pushBtn2;
#define ledPin 9
int brightness =128;
int delaytime=1000;
void setup()
{
// put your setup code here, to run once:
pinMode(2,INPUT_PULLUP);
pinMode(3,INPUT_PULLUP);
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
// put your main code here, to run repeatedly:
pushBtn1=digitalRead(2);
pushBtn2=digitalRead(3);
if(!pushBtn1 && brightness >0)
{
brightness=brightness-5;
}
else if(!pushBtn1 && brightness <255)
{
brightness=brightness+5;
}
analogWrite(ledPin,brightness);
Serial.println(brightness);
delay(1000);
}
訂閱:
張貼留言 (Atom)
algorithm
#include <iostream> #include <string.h> using namespace std; int main(int argc, char** argv) { for(int j=2;j<=100;j++)//j...
-
C语言怎样提取一个数的十位个位百位千位 1 设一个数为n,则在C语言中其个位、十位、百位、千位依次这样计算:n/1%10,n/10%10,n/100%10,n/1000%10 2 示例 #include<stdio.h> int main(){ in...
-
#include <at89x52.h> int P1table[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x02,0x04,0x08,0x10,0x20,0x40}; static const char P0tabl...
-
#include <at89x52.h> int P2table[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x02,0x04,0x08,0x10,0x20,0x40}; static const char P0tabl...



沒有留言:
張貼留言